> For AI agents: the complete documentation index is available at https://jig.md/llms.txt, the full documentation bundle is available at https://jig.md/llms-full.txt.

# Design understandable Jig projects

Build a project whose purpose, components, configuration, and results are easy to explain and change.
Jig supplies reviewed execution and locally authorized powers.
Flows supply the methods your application combines.

This guide covers project design.
The [quickstart](https://jig.md/start/index.md) teaches creation and execution.
The [project SDK](https://jig.md/spec/project-sdk.md) and [execution policy](https://jig.md/spec/project-policy.md) define exact host behavior.

## Choose the smallest useful boundary

Start with one method and add configuration when a real choice needs it.
Use these questions before introducing another component:

| Question                                                     | Starting point                                 |
| ------------------------------------------------------------ | ---------------------------------------------- |
| Can one method produce and check the result?                 | One Flow, invoked directly.                    |
| Does the same method need reusable local settings or powers? | A Binding for that configured use.             |
| Does another method contribute a distinct responsibility?    | A declared slot and explicit outcome handling. |
| Does only ordinary helper code need sharing?                 | A declared library dependency.                 |

## Start with the useful outcome

Describe the work the application makes possible before choosing its components.
Identify its inputs, promised result, required effects, and evidence of success.
Make uncertainty and unsuccessful outcomes part of that promise.
Choose the simplest composition that preserves the required authority and execution boundaries.

Use the [agent guide](https://jig.md/for-agents.md) to add FLOW and Jig skills for Agent-assisted project work.
Keep application instructions focused on its domain, acceptance criteria, and delegated authority.
Link to shared guidance instead of copying it into every project.

A reader should find the ordinary invocation without understanding the complete internal design.
Use a reviewed [project entrypoint](https://jig.md/reference/configuration.md#project-entrypoint) when it simplifies that invocation.
Keep advanced options with the situations that need them.
An entrypoint supplies defaults, while an explicit target bypasses those defaults.

## Build from meaningful Flows

Use FLOW's [design guidance](https://flow.jig.md/guide/design) for component boundaries, names, and public promises.
It covers decomposition, separate responsibilities, composition, and portable methods.
Use the FLOW skill when authoring or reviewing those methods.

Keep the application's coordination readable through its child calls and outcome handling.
Give each child the inputs and effects its capability needs.
Compose Flows through invocation slots rather than importing another Flow's private implementation.
Keep ordinary library helpers inside the method that owns them.

Make domain decisions explicit in the application or its methods.
Jig does not need a new primitive for each application policy, graph, or Agent technique.
Use [workflow design](https://jig.md/understand/workflows.md) to choose where code, Agent judgment, and additional coordination help.

## Keep responsibilities distinct

Give each choice one clear owner so unrelated changes remain local.
Use this division when reviewing a project:

| Responsibility                                                       | Owner                                        |
| -------------------------------------------------------------------- | -------------------------------------------- |
| Domain procedure, prompts, validation, and bounded control           | The Flow                                     |
| Purpose, acceptance policy, domain state, and user experience        | The application                              |
| Reusable local settings, exact child selections, and proposed grants | A Binding, when that configuration is needed |
| Agent clients, credentials, infrastructure, and acceptable powers    | The operator                                 |
| Review, admission, containment, limits, and accountable execution    | Jig                                          |

A Binding is a reusable project-local configuration for one Flow.
It lets local choices vary without rewriting the method.
The [project SDK](https://jig.md/spec/project-sdk.md) defines which choices it can express.

Keep presentation dependent on application state and observed facts.
Required work belongs in the method's explicit execution path.
Optional progress listeners should not acquire responsibility for completing the application.
Use [channels](https://jig.md/build/channels.md) for observation and [results](https://jig.md/build/results.md) for terminal evidence.

## Make configuration earn its place

Start with a direct Flow target when its empty settings and resolved dependencies satisfy the task.
Add a Binding for a meaningful configured use, explicit child selection, reviewed resource, or grant.
Create a Binding only when that configuration is useful.
Name each Binding by its configured role when several uses need distinction.

Use ordinary input for job data and `settings` for reviewed configuration.
Settings form one complete value and are not merged with per-run overrides.

Keep declarations inert.
Do not read files, request networking, fetch secrets, or run application work while evaluating declarations.

Use [default providers](https://jig.md/spec/project-sdk.md#default-providers-by-contract) for a project-wide choice of an ordinary contract implementation.
Use an explicit slot when one configured use needs a different implementation.
Jig resolves these choices during review and retains exact routes.
An explicit selection must match.
Jig does not silently fall back to another implementation.

Direct targets use their own empty settings and reviewed routes.
Running a Flow directly never borrows configuration from a Binding that happens to select it.
Verify the intended target with `jig inspect <target>` after approval.

**Example: Reusing a method with local guidance.**

Two teams could use one summary method with different reviewed audience guidance.
Separate Bindings could name those configured uses without copying the method.
If audience guidance changes for each job, supply it as ordinary input.
Use Bindings for choices the application treats as reusable configuration.

Keep small resource policies inline where they are used.
Extract a named [grant](https://jig.md/spec/grants.md) when reuse or independent ownership makes that policy easier to maintain.
Avoid layers of configuration that only rename another declaration.

## Keep powers with their owner

Let the operator choose Agent clients, credentials, and resource policies through the documented [setup](https://jig.md/build/agents.md).
Supply method instructions and bounded context through its interface.
Keep secrets out of Flow source, inputs, settings, artifacts, and diagnostics.
Declaring a dependency or installing a skill does not grant it execution authority.

Give each configured method only the powers and data needed for its responsibility.
Keep consequence policy in the application.
Respect approvals already delegated by its owner.
Do not add repeated manual approvals for authorized work.
An Agent's plausible answer cannot enlarge that authority.

Keep source changes and execution approval distinct.
Review the proposed source, selected implementations, settings, and grants before admitting changed work.
Use existing authorization to decide whether approval can be automated.
[Review](https://jig.md/reference/configuration.md#per-command-options) distinguishes dependency-resolution permission from approval of changed authority.

Treat a replacement as a change worth checking.
A matching contract establishes interface compatibility.
It does not establish equivalent judgment, effects, quality, or cost.
Review the new selection and exercise the application's acceptance cases.

## Make the project easy to move

Keep dependencies and resources with their declared owners.
Each importing Flow declares its own runtime dependencies.
The project manifest declares dependencies used by `jig.ts` and its `npm:` targets.

Use ordinary declared workspaces when sharing local libraries.
Follow [dependency preparation](https://jig.md/build/dependencies.md) for supported locks and required build output.

Use project-relative paths in declarations and declared attachments for external job files.
Pass attachment paths supplied by the host to the method.
Avoid assumptions about a developer's checkout, home directory, or ambient `node_modules`.
Binding attachments are reviewed resources, while per-run inputs are captured for each invocation.
Use [file guidance](https://jig.md/build/files.md) to choose the appropriate lifetime.

Keep project membership understandable when reorganizing directories.
`discover()` selects immediate members and does not recurse or interpret globs.
Update discovery roots or exact membership when moving components.
Binding package paths resolve from the project root.

Share source, declared dependencies, supported dependency locks, and `jig.lock` as appropriate for the project.
The protected `.jig/` directory contains local approval and execution state.
Do not transfer it as project source.
It does not grant execution permission on another host.
Review on the destination host with its operator's configuration and supported execution prerequisites.

## Make results and recovery understandable

Define what completion means before adding a progress display.
Required checks and effects must finish before the application reports its promised outcome.
Keep proposals visibly provisional until application checks accept them.
Choose output that lets the recipient understand both the result and any remaining decision.

Read execution status, application outcome, output delivery, and cleanup evidence separately.
A successful invocation can return an unsuccessful domain outcome.
Completion of an optional channel does not establish method completion.
Use [results](https://jig.md/build/results.md) to interpret those distinctions.
Use [troubleshooting](https://jig.md/reference/troubleshooting.md) to choose a diagnostic or recovery step.

Choose a retained output destination when the user needs files beyond temporary storage.
Jig never replaces an earlier result directory.
Preserve useful partial evidence when later work fails.
Do not describe an undelivered result as saved.

Bound repeated work by explicit stopping conditions and the applicable limits.
Wait for owned work to settle after interruption.
Preserve uncertainty when a remote effect might already have occurred.
Do not automatically replay such work to obtain a cleaner-looking result.
Cancellation cannot reverse a completed external consequence.

## Review the design through change

Use the project's ordinary public commands and artifacts to verify its claims.
Select the checks relevant to the boundaries changed and the qualities promised.
Test a useful result and an affected failure case.

| Probe       | Evidence to seek                                                                                                             |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------- |
| Explain     | A reader can trace the entrypoint, child responsibilities, required powers, and result without reading every implementation. |
| Reconfigure | A local policy or setting changes at its owner without unrelated method edits.                                               |
| Replace     | Another matching implementation passes the same application checks after review.                                             |
| Move        | A separate consumer project uses declared dependencies and local approval without private checkout knowledge.                |
| Fail        | Invalid input or a failed child produces an understandable outcome and preserves relevant evidence.                          |
| Stop        | Cancellation settles owned work and leaves external effects honestly described.                                              |
| Observe     | Removing optional observation preserves required work and the promised result.                                               |

Judge the whole consumer task, including setup, configuration, invocation, and recovery.
Remove indirection that adds no useful capability or enforceable boundary.
Keep boundaries that make the work understandable, replaceable, and accountable.
When host or provider prerequisites are unavailable, report inspection separately from execution.

### Change a conditional route

For a request such as “call C instead of B when J holds,” locate the caller, slot, and check that decide the route.
Use `jig inspect --flow` to find configured targets, distinct Bindings, and available powers.
Focus with `jig inspect --flow <target>` to see the decision alongside other callers, entrypoints, and uses of the same method.
Use `jig inspect --flow --all` for the complete project, including disconnected targets.

For a change to one configured use, compare its Binding's settings and slots with a use that already takes the requested route.
If an existing setting or slot selection gives the requested behavior, change it in that Binding.
When the route must vary between calls through one configured use, read the caller's guard, dispatch, and return handling.
Verify unresolved conditions, effects, and continuations in the source.
Use source directly when the view cannot describe the relevant behavior.
See [source behavior inspection](https://jig.md/build/results.md#inspect-source-behavior) for the command and its coverage.

When the caller needs a new slot, declare it with [`jig add-use`](https://jig.md/build/contracts.md#declare-a-collaborator-in-an-existing-flow).
Write the new conditional call and configure its target in source.

Follow the selected route into its evidence consumers: result records, saved reports, live views, and application guidance.
A correct dispatch change can leave these consumers describing the previous behavior.
Distinguish an application policy choice from an actual child's returned decision.
Matching the child's result shape does not establish that the child was invoked.

Review the edited source before running the affected inputs.
Assert the selected configured instance and the meaning of its result, rather than command success alone.
Exercise the changed condition and relevant preserved alternatives, including explicit choices, automatic selection, and affected failure or cancellation paths.
Report which alternatives were executed, which were inspected in source, and which remain unknown.

For a runnable example, [test a scoped route](https://jig.md/build/compose.md#test-a-scoped-route) with two approved Bindings in your regular test runner.

### Give one caller slot its own child Binding

When several callers share a Binding, use `jig specialize-slot` to give one caller a different child selection.
Identify the caller Binding, its slot, and the child slot with `jig inspect --flow`.
For example, an audit import can use a stricter validator while standard imports keep the original.
This example starts with a retained approval.

```sh
jig specialize-slot binding:audit --slot import --as audit-import --select validate=binding:strict-validator
jig check --diff
```

Jig copies the selected import Binding beside its original and changes its `validate` slot.
It updates the audit caller's `import` slot to use that copy.
If `jig.ts` lists Bindings in a literal array, Jig adds the new path to that array.

Open the reported declaration paths to review the edit.
Use [`jig check --diff`](https://jig.md/build/results.md#check-working-composition) when the project has a retained approval.
Check that the caller's `import` slot selects the new Binding.
Confirm that the diff omits every other existing caller slot.
Use `jig check` before the first approval.

Run `jig review` separately before running the new configuration.
Use ordinary source edits for computed or shared declarations and conditional call sites.
See the [CLI contract](https://jig.md/spec/cli-experience.md#give-one-caller-slot-its-own-child-binding) for supported declaration shapes and interruption behavior.
