#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 teaches creation and execution. The project SDK and execution policy 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:
#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 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 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 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 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:
A Binding is a reusable project-local configuration for one Flow. It lets local choices vary without rewriting the method. The project SDK 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 for observation and results 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 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 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. 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 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 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 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 to interpret those distinctions. Use troubleshooting 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.
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 for the command and its coverage.
When the caller needs a new slot, declare it with jig add-use.
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 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.
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 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 for supported declaration shapes and interruption behavior.