---
name: fragment-quickstart
description: Use when a user wants to try Fragment or start a new integration. Builds and runs a small TypeScript application that posts a Fragment ledger entry and verifies its balance, using the Fragment CLI and hosted Fragment services.
---

# Fragment quickstart for coding agents

Help the user create a working Fragment schema and ledger that model their funds flow.
Integrate ledger entries and balance queries into their application, or build a new example with them.
Start with CLI installation and account setup so the user has working tools before choosing an integration goal.
Then understand their company and project.
Use the user's laptop and hosted Fragment services. No MCP connection or local dashboard is required.

## Work in small steps with the user

Start with one small funds flow and one observable balance outcome.
Keep other flows in a short “Later” list. Do not model or implement them during this first milestone.

Stages 2 through 5 contain required checkpoints. At each checkpoint, show the work, ask the stated question, and stop.
End the turn and wait for the user's response before starting the next phase.
An invitation to correct the work while you continue is not a checkpoint.
Starting the quickstart does not approve every later stage. Diagram approval does not approve schema publication or application changes.
Use an answer already given for that specific checkpoint; do not ask the same question twice.
After a correction, replace the superseded facts in the diagram, amounts, and expected balances.
Show the revised work and ask for agreement again. A correction does not approve the next phase.

Each review question resolves a business decision about scope, accounting, or implementation.
Build the reply around that decision:

1. Show the result, including the diagram or CLI output required for that review.
2. Explain what the result means for the user's product and identify any assumptions to confirm.
3. Ask one direct decision question, then end the turn and wait.

For a flow review, show the diagram and follow it with a check-in such as:

> This records the purchase, the marketplace fee, and the amount owed to the seller.
> Settlement and payouts remain for later.
> Does this show the flow you'd like to start with?

Before sending a review reply, remove commentary about why an instruction requires you to pause.
Do not quote or link this quickstart, name stage numbers, or cite checkpoint rules to justify waiting.
Follow the pause rule by ending the turn after the question. Keep the explanation focused on the user's decision.
Links to the user's schema or other reviewed artifacts are useful when they help assess the result.
End each review response with the user's decision question. Place status summaries and limitations before that question.
Describe only the work authorized for the current phase when announcing your next action.

| Checkpoint     | Show the user                                                                  | Wait for                                                                    |
| -------------- | ------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| End of stage 2 | Company and project summary                                                    | Confirmation or corrections to the context                                  |
| End of stage 3 | One small funds-flow diagram and deferred flows                                | Agreement on the flow to track first                                        |
| End of stage 4 | The milestone, example amounts, and expected balances                          | Approval to model this scope locally                                        |
| End of stage 5 | Account tree, entry definitions, scenario results, and proposed implementation | Approval to publish the schema, create a ledger, and change the application |

Keep progress visible between checkpoints. Explain what you are about to inspect, model, or verify before running tools.
After tool runs, show their relevant results in your response and explain what they establish.
Tool activity and saved files do not substitute for showing results in the conversation.
During longer work, send brief progress updates describing what you learned and what remains.
When answering clarifying questions, link to the relevant public Fragment documentation that supports the explanation.
When public documentation informs a decision, include a direct link while explaining that decision.
Link to the specific page or section. Local reference copies do not replace public links in user-facing explanations.

## What to expect

Before starting setup, show the user this brief introduction:

> This quickstart will install the Fragment CLI and set up a Fragment account for you. Then we'll model and simulate your funds flow and create a working schema and ledger. Finally, we'll connect ledger accounting to your app or a new example.

## 1. Set up the CLI and Fragment account

Goal: leave the user with an installed CLI, a Fragment account and ledger workspace, and verified API credentials.
Complete this stage before company discovery or application changes.
Use a workspace that supports the ledger product. No Payments-specific region restriction applies to this quickstart.

Run the setup commands yourself through your terminal tool, including installation, credential checks, and browser login.
The user handles browser sign-in, account creation, and authorization approval.
Do not hand terminal commands back to the user when you can execute them.
If a command needs tool approval or additional execution permissions, request those through the environment's normal approval mechanism.
Ask the user to run a command only when execution is unavailable or remains blocked; explain the specific limitation.

Locate the CLI with `fragment version` and inspect `fragment login --help`.
If it is missing, install it:

```bash
curl -fsSL https://fragment.dev/install.sh | sh
```

Follow the installer's output for prerequisites and the executable path.

Update an outdated published CLI with `fragment update`.
Keep an explicitly supplied development CLI and environment instead of replacing them.
Check credentials with `fragment login --test` without printing credential files.
If credentials work, use that workspace unless the user requests another.
Otherwise run:

```bash
fragment login --browser
```

If the localhost callback fails with `EPERM` or `EACCES`, request permission to bind the loopback listener and retry.
Use the terminal tool's supported escalation mode when required.
After permissions are granted, rerun the failed `fragment login --browser` command with the same workspace option, if supplied.
Complete browser authorization before running `fragment login --test` to verify the saved credentials.
Passing credential verification does not replace unfinished browser login or a requested workspace change.
If the environment cannot grant those permissions, explain that limitation before asking the user to run login locally.

Start browser login in a persistent terminal session. Show the browser link and keep the process running during sign-in.
Poll or resume that session to receive the callback and finish login after the user approves in the browser.
Do not stop the login process while waiting or ask the user to start a second copy.
New users complete account and workspace setup in the dashboard before approving API-client creation.
Browser login provisions the API client and saves its credentials automatically after approval.
The dashboard discovers the regional authorization service after workspace selection.
Do not pass `--workspace` for a new user. For a known workspace, pass `--workspace <workspace-id>`.
The browser and CLI must run on the same machine for the callback to work.
If login expires, rerun browser login; completed signup and workspace creation remain available.

The CLI saves credentials in `${FRAGMENT_PATH:-$HOME/.fragment}/auth.json`.
Read credentials from application code or the project's secret configuration; never print them in agent output.
Do not ask the user to copy credentials or create an API client manually.
Keep credentials server-side and out of source control.

After browser login, run `fragment login --test` to verify the saved credentials.
Do not report setup as complete until this check succeeds.

Continue directly to company and project discovery once the connection check succeeds.

## 2. Understand the company and project

Goal: establish shared context for choosing the first funds flow to track.

Start with these questions together:

> Can you share your company website and any documents you'd like me to use?
> Does this folder contain the repository you want to integrate with, or are we starting a new project?

The website and documents are optional. Continue with the information the user provides.
Read the supplied sources to understand the product, its customers, and how money moves through their business.
Treat inferred funds-flow behavior as an assumption until the user confirms it.

If the user selects an existing repository, inspect its instructions and relevant code before asking technical questions.
Look for:

- The README, language, framework, package manager, and test commands.
- Frontend pages and backend routes or jobs that handle payments.
- Existing payment integrations and order, invoice, or customer models.
- Configuration conventions and relevant tests, without printing secrets.

Reuse the project's language and conventions. Do not create a separate demo project for an existing integration.
For a new project, ask about stack preferences only when the supplied context does not establish them.
Wait to create the project until the first ledger integration goal is chosen.

Finish this stage with a short summary of:

- What the company does and who pays for its product or service.
- Whether this is an existing or new project, including the stack and relevant application components.
- Existing payment functionality and candidate integration points, when a repository is available.
- Assumptions and missing context that affect the payment flow.

Do not install project dependencies or change application code during context gathering.
Checkpoint: ask “Does this match your company and project?” End the turn and wait for confirmation or corrections.
Use the confirmed context to guide later questions and implementation choices.

## 3. Propose the first funds flow

Goal: identify one useful funds flow to track with minimal questioning.

Use the gathered context to propose a likely first funds flow in the user's business terms.
If the context does not establish a flow, ask:

> What's the first funds flow you'd like Fragment to help track?

Propose the smallest useful slice of the business's funds flow, usually one event and the balance it changes.
Include related steps only when they are necessary to explain that result.
For a marketplace, start with recording one purchase, its fee, and the seller amount owed.
Defer settlement, withdrawals, refunds, and other flows unless the user chooses one of them as the first goal.
Summarize deferred flows in the “Later” list without designing their accounts or entry types.
Keep existing payment providers and checkout behavior.
If no provider exists, model the financial events without adding payment execution to this quickstart.
Label who executes each movement in the diagram. Explain that ledger entries record events and do not send money.

After their response, ask one focused follow-up only when the answer changes the integration approach.
For example:

> When should the seller be able to withdraw their earnings?

These are conversation examples, not a questionnaire. Ask at most two focused questions per turn.
Do not ask the user to repeat facts available in the website, documents, or repository.
Defer questions about other funds flows until they affect the chosen goal.

Include a diagram whenever you propose or revise a flow.
Show the participants and the direction of money movement. Label known amounts, fees, and currencies when relevant.
Label assumptions and unknown steps. Distinguish money movement from application requests and ledger updates.
Use plain-text diagrams in fenced `text` blocks within Markdown. Do not use Mermaid.
Use labeled boxes and arrows. Keep diagrams compact enough to read in a narrow terminal.
Keep node and arrow labels short. Explain details below the diagram instead of inside labels.
Split large flows into separate payment, availability, and payout diagrams when needed.
Use a vertical layout when a horizontal diagram would be too wide.
Update the diagram when the user clarifies the flow.

For example, a booking business might start with this business flow:

```text
[Customer] -- pays for a booking --> [Business]
```

Adapt the diagram to the user's business. Do not add fees, transfers, or settlement timing without supporting context.
Below the diagram, explain which ledger entries record the events and which balances the user can inspect.
Finish this stage with the business event to support and any unresolved assumption that blocks it.
Checkpoint: show the proposed diagram and ask “Shall we track this small flow first and leave the others for later?”
End the turn and wait. Do not create schema files yet.

## 4. Agree on the first integration goal

Goal: choose a small, observable outcome in the user's application.

Read the [Ledger overview](https://fragment.dev/api-reference/ledger-overview) before recommending an implementation approach.
Recommend the ledger events and balances that make the flow observable:
Choose the relevant outcome; these examples are not a checklist of flows to implement.

| Business event or question                   | Ledger behavior                                        |
| -------------------------------------------- | ------------------------------------------------------ |
| A payment is collected or a transfer settles | Post an entry for the confirmed event                  |
| A marketplace charges a fee                  | Record the fee and the amount owed to the seller       |
| Funds become available to withdraw           | Move the amount between pending and available accounts |
| A seller withdraws funds                     | Record the external payout and reduce the amount owed  |
| The user needs to see what remains           | Query the relevant ledger account balances             |

Explain the recommendation in business terms before introducing account types or entry configuration.
Agree on the accounting coverage and which external systems provide the events.
Use only the events needed for the selected balance outcome. Keep the deferred flows outside this milestone.

Describe the milestone in one or two sentences. For a booking application, it could be:

> Record a booking payment and the business's fee in a Fragment ledger.
> Your application shows the amount owed to the provider after that booking.

Identify the existing screens, routes, or jobs involved. For a new project, propose a stack and application structure that supports this outcome.
Resolve business assumptions that affect the milestone, and invite the user to correct the proposed goal.
Use one example transaction to establish the expected application behavior and financial result.
Keep the updated flow diagram visible when explaining these choices.
State the example amount, any known fees, and expected balances before proposing schema details.
Checkpoint: ask “Should I model this milestone locally using these amounts and expected balances?” End the turn and wait.
Approval here permits creating and simulating the local schema and scenario together. It does not permit publication or application changes.

## 5. Model and simulate the funds flow

Goal: review a local schema together with a simulated scenario that demonstrates the agreed funds flow.

Model only the milestone agreed in stage 4. Do not expand it to cover the whole business.
Represent its financial events with ordinary ledger entry types and scenario entry events.
Explain that the schema describes accounting rules and that simulation does not send money.
If starting directly at this stage, confirm the small scope and expected balances before creating the model.
Build, validate, and simulate the schema and scenario as one stage, then request review of the combined result.
Keep progress visible throughout. Do not require a separate schema approval before creating or simulating its scenario.

### Reference guides

The [guide index](https://fragment.dev/skills/mcp-guides.md) lists the available ledger-design references.
Each guide has its own Markdown file. Read only the topics relevant to the user's funds flow.
These guides include MCP tool examples; apply their accounting concepts using this quickstart's CLI workflow.

- [Ledger fundamentals](https://fragment.dev/skills/mcp-guides/basics.md): Account types, template paths, entries, balancing, and amount expressions.
- [Design methodology](https://fragment.dev/skills/mcp-guides/design-methodology.md): Model one funds flow and test expected balances with scenarios.
- [Ledger design principles](https://fragment.dev/skills/mcp-guides/patterns.md): An overview of custody, obligations, balance states, and links to detailed design guides.
- [Example schemas](https://fragment.dev/skills/mcp-guides/example-schemas.md): Choose a starting schema from the template library.
- [Consistency](https://fragment.dev/skills/mcp-guides/consistency.md): Strong and eventual consistency for balances, lines, and conditions.
- [Multi-currency](https://fragment.dev/skills/mcp-guides/multi-currency.md): Multiple currencies, custom assets, foreign exchange, and balancing per currency.
- [Schema evolution](https://fragment.dev/skills/mcp-guides/schema-evolution.md): Version entry types, manage account lifecycles, and migrate historical data.
- [Reconciliation](https://fragment.dev/skills/mcp-guides/reconciliation.md): Link external financial accounts and reconcile transactions.
- [Card issuing](https://fragment.dev/skills/mcp-guides/card-issuing.md): Authorization holds, captures, settlement, and returns.
- [Invoicing](https://fragment.dev/skills/mcp-guides/invoicing.md): Receivables, invoice aging, merchant advances, and write-offs.
- [Revenue recognition](https://fragment.dev/skills/mcp-guides/revenue-recognition.md): Pending and earned revenue, with periodic revenue sweeps.
- [CLI manual](https://fragment.dev/api-reference/ledger-cli-commands): Installation, authentication, and command options.

### Build and simulate the schema

For a new schema, download the [minimal schema example](https://fragment.dev/quickstart-schema.json) directly into the project's chosen schema file.
Use this exact URL rather than searching the web for a blank schema. Do not use the deprecated `fragment init` command.
The example includes accounts, an entry type, and a scenario. Adapt them together to the approved milestone.
Remove unrelated example definitions. If a schema already exists, read and update it instead of replacing it.
Keep the user's agreed amounts and fees; sample values are not business requirements.
The account tree belongs in `chartOfAccounts.accounts`, and entry definitions belong in `ledgerEntries.types`.
Scenarios belong in `scenes`; each entry event uses `eventType: "entry"` and an `entry` object.
Read the relevant design guides for account templates and other features the selected flow actually needs.

Create or update the schema file using the project's conventions and the ledger-design references.
Preserve existing schema definitions that the selected flow does not change.
Configure only the accounts and entry types required for the selected milestone.
Use template schemas as references; do not import unrelated flows or optional features into the initial model.
Add a named scenario to the schema's `scenes` array that represents the agreed flow.
Use entry events for every scenario step. Do not add Payment Types or payment scenario events.
Choose representative amounts and identifiers from the established context, and label assumptions.
Store amounts as integer minor units expressed as strings.
Keep application code, SDK installation, and new-project scaffolding for the integration stage.

Validate the schema:

```bash
fragment verify-schema --path <schema-file>
```

Report whether validation succeeded. If it failed, show the relevant errors and explain the correction before retrying.

Whenever the user needs to see schema details, use the CLI's pretty-print command:

```bash
fragment print-schema --path <schema-file>
```

Use `--account <account-name-or-path>` or `--entry <entry-name>` to focus on a single account or entry.
These flags are mutually exclusive. Omit both for the full chart of accounts and entry overview.
Display the command's Markdown output directly in the conversation alongside the funds-flow diagram when relevant.
Use this view when explaining the schema or reviewing changes with the user.
Always show the draft account tree and entry overview here, even when the user has not requested schema details.
Before presenting it, confirm the printer includes every intended account, entry type, and posting line.
A successful validation command alone does not establish that the file contains the intended model.
If entries or lines are missing, correct the schema structure and rerun validation and printing before requesting review.
Explain how each entry changes the balances in the agreed example.
Show the local schema file path alongside its scenario results. Keep modeling local until the publication checkpoint is approved.

Simulate the scenario with the CLI before requesting review of the model:

```bash
fragment simulate-scenario --path <schema-file> --scenario "<scenario-name>" --step 1
```

Steps start at 1; step 0 is not allowed.
Run through the final step, inspecting intermediate steps where the movement or ownership of money changes.
Show the CLI output directly in the conversation, including the selected entry, posting lines, and account balance tree.
After each meaningful step, show its output and explain the balance changes before moving to the next step.
Do not silently run every step and report only that simulation passed.
Keep the funds-flow diagram alongside the simulation and update it when the model changes.
Explain each meaningful step in business terms: who holds the money, who is owed, and what remains available.
Check the resulting balances against the expected outcome, including configured fees and amounts owed to each participant.

If validation or simulation fails, fix the schema or scenario and rerun the affected steps.
Ask only about unresolved assumptions that affect the selected goal.
Treat simulation results as an accounting preview; verify posted entries and queried balances against it during integration.
Review the account tree and entry definitions alongside the scenario, intermediate balances, and expected-versus-actual comparison.
Explain how the scenario demonstrates the schema's rules and finish with the schema and ledger you propose to publish.
Describe the application changes you propose and identify the workspace where you will publish.
If the workspace is unverified, say so instead of inventing an identity or link.
Checkpoint: ask “Shall I publish this schema, create the ledger, and connect this milestone to your application?”
When hosted execution is unavailable, describe the proposed next steps and ask for review of the results and next-step choice.
For example: “Do these balances look right, and would you like to plan publishing this model in your workspace?”
Keep this review question even when the current session can only model locally.
End the turn and wait. Do not publish, create hosted resources, install SDKs, or change application code before this response.
Carry only the approved schema, scenario, and implementation scope into the next stage.

## 6. Implement and verify the agreed goal

Goal: create a working hosted schema and ledger, then connect transactions and balances to the user's project.
Begin only after the stage 5 publication and implementation checkpoint is approved.

Follow the [CLI reference](https://fragment.dev/api-reference/ledger-cli-commands) and [Ledger SDKs](https://fragment.dev/api-reference/ledger-sdks).
Use the project's package manager, configuration conventions, and test commands.
For a new project, create the agreed application without overwriting existing files.

### Publish the schema and create the ledger

Use the schema validated during simulation.
Store it with `fragment store-schema --path <schema-file>`.
Create the ledger with `fragment create-ledger --schema <schema-file> --name "<ledger-name>" --ik <stable-ledger-key>`.
Inspect command help before running commands and use stable idempotency keys when retrying resource creation.
Confirm the schema and ledger exist in the authorized workspace before reporting success.
Separate schema and ledger setup from application requests.

### Connect transactions and balances

Generate operations with `fragment gen-graphql --path <schema-file> --output <queries-file>`.
Follow the SDK documentation for the project's language to generate its client.
Connect ledger entry posting to the relevant backend routes, jobs, or trusted provider events.
Use stable provider or business identifiers for idempotency so retries do not duplicate accounting.
Amounts are integer minor units expressed as strings. Use the currency precision configured in the schema.
Query account balances from Fragment and display them in the relevant application screens when applicable.
Keep credentials on the server.

Preserve the distinction between recording a financial event and executing a payment.
Record actual collections, settlement, and payouts from trusted confirmations when a payment provider is connected.
If no provider exists, expose clearly labeled test actions that post example ledger entries without moving money.
Use those actions to exercise the ledger integration. Do not build payment execution as part of this quickstart.
Preserve any modeled request, reservation, failure, and return accounting.

### Verify the result

Run the project's relevant checks and exercise the agreed transaction flow against the hosted ledger.
For an existing integration, use test events or a provider's sandbox confirmations.
For a new example, use the explicitly labeled test actions.
Verify the posted entry identifiers and queried account balances against the simulated outcome.
Check intermediate balances when funds change ownership or availability.
Repeat the same event and verify idempotency prevents duplicate entries or balance changes.
Do not equate checkout confirmation with final settlement.

Report the schema and ledger created, changed files, how to exercise the feature, and entry identifiers actually observed.
Include the verified balances.
Explain which events are test inputs and which come from a connected external system.
If a step fails, report the failing operation without printing secrets or claiming the milestone is complete.

## 7. Choose the next accounting goal

Goal: extend the ledger integration based on the user's product needs.

Summarize what now works and update the flow diagram to show the implemented portion.
Recommend one useful next capability, such as refunds accounting, payout reservations, reconciliation, or another balance view.
Ask whether the user wants that next step or another funds flow.
Continue with one flow at a time.
