jig-plan 0.0.0-stage → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ # Security in a plan
2
+
3
+ Read this when a slice touches authentication or authorization, user input, secrets, dependencies, MCP servers, production credentials, or untrusted content such as issues, PR text, web pages or tool output. Security prompting reduces issues but doesn't remove them, so turn each answer into a check or a human review step.
4
+
5
+ ## Generated code
6
+ - **New route or handler:** add a `security` check that calls it without credentials and with another user's credentials, and expects a refusal.
7
+ - **Input:** where does it come from, where is it validated, and where is it encoded on output (HTML, SQL, shell, paths)? Use parameterized queries and the framework's escaping; don't hand-roll either.
8
+ - **Passwords, tokens, crypto:** use the platform's library (bcrypt or argon2, the framework's session handling). Never write these by hand.
9
+ - **Auth paths get a human read.** List them in the slice Goal so the reviewer and the owner know where to look.
10
+ - **CI:** if the repo has no SAST or dependency scanner, `jig doctor` reports it. Adding one is a separate slice, not a side effect.
11
+
12
+ ## Lethal trifecta
13
+ A coding agent usually has private data, untrusted content and a way to send data out (Willison, June 2025). When a plan feeds untrusted content to the agent (summarizing issues, reading web pages, calling a new MCP server), say which leg the session breaks: no secrets in reach, no network egress, or no untrusted input.
14
+
15
+ ## Secrets
16
+ - Keep them out of the agent's environment. `jig doctor` reports `.env` files and credential paths with no deny rule.
17
+ - Use short-lived credentials, and run a secret scanner (gitleaks or trufflehog) in CI.
18
+ - Never put a secret in a plan, a check command or a log entry.
19
+
20
+ ## Supply chain
21
+ - A new dependency is a one-way door. Record its name, registry page, age, weekly downloads and maintainer in Decisions. Hallucinated package names recur across runs (43% recurred in every one of 10 runs; Spracklen et al., USENIX Security 2025), so attackers register them.
22
+ - Install with the lockfile (`npm ci`, `pip install -r` with hashes) and review lockfile diffs.
23
+ - The jig Bash hook asks before any agent-run install that names a package.
24
+
25
+ ## Repo config is an execution vector
26
+ A malicious `.claude/settings.json` or `.mcp.json` has run code or leaked API keys before the trust dialog in past Claude Code versions: CVE-2025-59536, CVE-2026-21852, CVE-2026-33068 and CVE-2026-40068, all patched. In an unfamiliar repo, read those files before running an agent there, and keep Claude Code updated. `jig doctor` lists them; it never edits them.
27
+
28
+ ## MCP servers
29
+ Each server is third-party code holding real credentials, and its tool descriptions can carry injected instructions. Allowlist servers, pin versions, use read-only tokens, and prefer fewer, narrower tools.
30
+
31
+ ## Blast radius
32
+ - No production write access for agents. Use separate dev and prod credentials, and a read-only database user for exploration.
33
+ - Review infrastructure plans (`terraform plan`, `pulumi preview`) before apply. Apply is a one-way door.
34
+ - `--dangerously-skip-permissions` belongs only in an isolated container or VM with no credentials.
@@ -0,0 +1,43 @@
1
+ # Sizing a plan
2
+
3
+ Size by what has to be checked and what can't be undone, not by how long a person would take. Neither agents nor planners estimate time well: Fable 5.1 missed requested runtimes by a typical factor of 2.9 (AgentTime, arXiv 2610.09944), and one jig-planned project shipped in 15 days against a 30-week plan. Agent success does fall as a change spreads across more files, so file count is a useful signal.
4
+
5
+ ## Tiers
6
+
7
+ | Tier | What you produce | Use it when all of these hold |
8
+ |---|---|---|
9
+ | 0 inline | Up to 5 lines in chat, no file | One reversible change; no contract, schema or data change; an existing check covers it, or one command proves it |
10
+ | 1 brief | `PLAN.md` human layer plus 1 to 3 slices; checks as commands | Several files or one new behaviour; everything reversible; no one-way door |
11
+ | 2 full | Plus `checks.json`, a jig-reviewer pass, and a gate if a one-way door applies | Any one-way door, a new dependency, an auth or data path, more than 3 slices, or work that spans sessions |
12
+ | 3 program | An index plan whose slices point to child plans, and an ADR per one-way door | Work that can't be checked as one plan, or more than one person working in parallel |
13
+
14
+ Signals that move a plan up a tier:
15
+
16
+ - **A one-way door:** schema or partition-key design, public API contracts, the auth model, data deletion, production or infrastructure changes, new runtime dependencies, or a scope change.
17
+ - **Breadth:** more than about 5 files, or more than one module boundary.
18
+ - **Data at risk:** migrations, backfills, deletes, or anything that writes where users store their work.
19
+ - **Unfamiliar ground:** you couldn't find an existing pattern in the repo to follow.
20
+ - **More than one person**, or parallel agents in separate worktrees.
21
+ - **No fast verify command** in the repo. Add slice S0 to create one, because every later slice depends on it.
22
+
23
+ When unsure between two tiers, take the smaller one and escalate as soon as a signal appears. Log the escalation. A plan that's too heavy for its task costs the reader more than it saves: Böckeler watched Kiro turn a small bug into 4 user stories and 16 acceptance criteria. A bad plan also does worse than no plan (Liu et al., arXiv 2604.12147).
24
+
25
+ ## Tier 0 format
26
+
27
+ ```
28
+ Plan: <outcome in one line>
29
+ Files: <paths>
30
+ Done when: `<command>` <passes / prints X>
31
+ Risk: <only if one exists, with how you'd notice it>
32
+ ```
33
+
34
+ Then do the work. Tier 0 never stops for approval unless the change turns out to need a gate, and if it does, it isn't tier 0.
35
+
36
+ ## Slices
37
+
38
+ A slice is one increment you can check. Each slice:
39
+
40
+ - **Is vertical**, ending in something that runs, rather than a layer such as "all the models" with nothing to verify until the end. Order work inside a feature as contract, then fixture data, then behaviour, then integration.
41
+ - **Fits one session.** Anthropic's long-running harness gives each session one feature. Sessions that try more declare victory early.
42
+ - **Names the files it may touch.** That list keeps the change in scope, and the edit hook warns outside it.
43
+ - **Ends with its checks green and a commit.** The next slice starts from a known-good state, and a bad slice reverts cleanly.
@@ -0,0 +1,22 @@
1
+ # Plans with more than one person
2
+
3
+ Use this when `git shortlog -sn --since=90.days` shows more than one active author, when the owner says others will work on the plan, or when several agents will run in parallel.
4
+
5
+ ## What changes in the plan
6
+
7
+ - **Decisions:** add `Owner:` to a decision that someone other than the plan's author has to make. One-way decisions record who decided in `Decided: <who> <date>`.
8
+ - **Questions:** each question names who answers it: `- <question> Owner: <name>`.
9
+ - **Slices:** add `Owner:` when different people or agents take different slices.
10
+ - **ADRs:** at the program tier, each one-way decision gets a short ADR in the repo's ADR folder (or `docs/adr/NNNN-<slug>.md`) covering context, decision and consequences. Link it from Decisions. ADRs outlive plans, and they are the system model agents read before changing a boundary.
11
+
12
+ ## Parallel work
13
+
14
+ - **One agent per git worktree**, so agents don't overwrite each other's files.
15
+ - **Split slices along module boundaries**, so parallel slices don't touch the same files. Overlapping `Touch:` lists mean a likely merge conflict, so sequence those slices instead.
16
+ - **Contracts first.** The slice that defines a shared interface or schema lands before the slices that build on it.
17
+ - **Each worktree runs `jig verify` for its own slice.** Merge only green slices.
18
+
19
+ ## Review
20
+
21
+ - **One reviewer per slice**, with their depth set by risk: auth paths, migrations and public contracts get a line-by-line human read; the rest get the jig-reviewer diff pass plus a skim.
22
+ - **The PR description explains the change** in two or three sentences, links the plan and slice, and gives the evidence line from the Log. Required explanations, and a named owner for each module, keep the team's understanding of the code level with the code itself.
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: build
3
+ description: Carries out an approved jig plan one slice at a time. It resumes from the plan's Now line, writes the acceptance checks before the code, implements, runs `jig verify --record`, logs what changed, and commits. Use when continuing or executing a plan under docs/plans/, when asked to work the next slice or pick up where a previous session stopped, or right after the plan skill hands off.
4
+ allowed-tools: Read Glob Grep Bash(jig status:*) Bash(jig lint:*) Bash(git status:*) Bash(git diff:*) Bash(git log:*)
5
+ argument-hint: plan path or slice ID (optional)
6
+ ---
7
+
8
+ # Build
9
+
10
+ Work one slice per session. A long session degrades as context fills, and it tends to take on too much and declare victory early. The plan file holds everything a fresh session needs.
11
+
12
+ ## 1. Resume
13
+
14
+ Run `jig status`, then read the plan: its human layer, the slice you're working on, and the last few Log entries. Run `git status` and `git log -3`, so you start from what's actually there, not from memory.
15
+
16
+ - **A slice already `[doing]`:** continue it. Check its Log lines to see how far it got.
17
+ - **Otherwise:** take the first `[todo]` slice, mark it `[doing]`, and update `Now:`. Set the plan's status to `building` if it's still `approved`.
18
+ - **The plan isn't approved:** stop and send the owner back to it. Building an unapproved plan skips the gate they rely on.
19
+
20
+ Run the repo's fast checks before changing anything. If they already fail, log that and tell the owner, so their failures aren't blamed on your work.
21
+
22
+ ## 2. Checks first
23
+
24
+ For each acceptance check in the slice that doesn't exist yet, write it from the spec (the plan's Outcome and the slice Goal) before writing the code it checks. Run it and confirm it fails for the right reason. A check that passes before the feature exists is checking nothing.
25
+
26
+ List each acceptance test file under `protects` in `checks.json`. From then on, the edit hook asks before anyone changes it.
27
+
28
+ **If a test and the spec disagree, stop.** Don't edit the test to make it pass, and don't special-case the code to satisfy it. Report the conflict to the owner with both sides quoted. Editing tests to go green is the most common way agents fake progress, and it's the one prompts least reliably prevent.
29
+
30
+ ## 3. Implement
31
+
32
+ - **Stay inside the slice's `Touch:` list.** If you need another file, add it to Touch and say why in the Log. The edit hook warns when you go outside it.
33
+ - **Reuse before adding.** Before writing a new helper, search for an existing one.
34
+ - **Let failures show.** Don't add an empty or broad `catch`, or a fallback that hides an error, to get past a problem. Handle the error the slice says to handle, and let the rest surface.
35
+ - **Follow the repo's existing patterns** for structure, naming, error handling and tests.
36
+ - **Ask before installing.** A new dependency is a one-way door. If the plan doesn't already decide it, ask the owner. The Bash hook asks too.
37
+
38
+ ## 4. Verify
39
+
40
+ Run `jig verify --record` for the slice. It runs the slice's checks, prints one line per check, and appends the result to the Log. That Log line is the evidence the slice is done. A sentence saying the tests pass is not evidence.
41
+
42
+ - **All green:** go to step 5.
43
+ - **A check fails:** fix the code, not the check, and verify again.
44
+ - **A check can't run here** (missing service, credentials, hardware): say so in the Log and to the owner. Don't count it as passing.
45
+
46
+ At the full tier, hand the slice to the `jig-reviewer` agent in diff mode, with the plan path and slice ID. Fix the findings, or log why one doesn't apply.
47
+
48
+ When the slice changes UI and the loupe skill is available, run it on the affected screens if the slice's done-when calls for it.
49
+
50
+ ## 5. Close the slice
51
+
52
+ 1. Mark the slice `[done]` and update `Now:` to the next slice.
53
+ 2. Append a Log line saying, in two or three sentences, what changed and why. This is for whoever reads the code next, including the owner checking they still understand their system.
54
+ 3. Run `jig lint` on the plan.
55
+ 4. Commit the slice with a message that says what it does.
56
+
57
+ Then stop and report to the owner:
58
+ - the slice
59
+ - the evidence line
60
+ - anything you couldn't verify
61
+ - the next slice
62
+
63
+ Start the next slice in a fresh session unless the owner asks you to keep going.
64
+
65
+ When every slice is done and the Outcome's done-when commands pass, set `Status: shipped` and log it.
66
+
67
+ ## When something goes wrong twice
68
+
69
+ If you make the same mistake a second time, or the owner corrects the same thing twice, use the guard skill to turn it into a hook, lint rule or test.
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: guard
3
+ description: Turns a repeated agent mistake, an owner's repeated correction, or an incident cause into a deterministic guardrail, such as a permission deny rule, a hook, a lint rule, a test or a type, instead of another reminder in prose. Also audits a repo's harness with `jig doctor`. Use when the same problem has come up twice, after an incident or postmortem, when asked to "stop this from happening again", or when asked whether a repo is ready for agent work.
4
+ allowed-tools: Read Glob Grep Bash(jig doctor:*) Bash(git log:*) Bash(git diff:*)
5
+ argument-hint: the mistake or incident to guard against, or "doctor"
6
+ ---
7
+
8
+ # Guard
9
+
10
+ A correction in prose is advisory. The model follows it less as instructions pile up, and the next session may never see it. A mistake that has happened twice will happen again, so give it a mechanism that holds whether or not anyone remembers.
11
+
12
+ ## 1. Name the failure precisely
13
+
14
+ Write down:
15
+ - what happened
16
+ - where: file, command, or tool call
17
+ - how it was caught
18
+ - what it cost
19
+
20
+ Find the earlier occurrence (plan Logs, git history, or the conversation), because "twice" should be a fact. If it has only happened once, fix it, note it in the plan Log, and stop here.
21
+
22
+ ## 2. Choose the mechanism
23
+
24
+ Use `${CLAUDE_PLUGIN_ROOT}/references/mechanisms.md`. Prefer, in this order:
25
+
26
+ 1. **A test, type or lint rule** when the mistake shows up in the code. It fails in CI for anyone, agent or human. For example: a lint rule against empty `catch`, a type that makes the invalid state unrepresentable, or a test for the bug.
27
+ 2. **A permission deny rule** when the mistake is an action that must never happen, such as reading `.env`, writing migrations or pushing to main.
28
+ 3. **A hook** when it must be checked during the agent's work and a deny rule is too blunt. Use `ask` when exceptions are legitimate, so a person decides each one.
29
+ 4. **One line in CLAUDE.md or AGENTS.md** only when it's a fact the repo doesn't already say and no check can decide it.
30
+
31
+ ## 3. Propose, then apply what's yours to change
32
+
33
+ Show the owner the mechanism, the exact change, and how you tested that it catches the failure: ideally, run it against the original mistake and see it fire.
34
+
35
+ - **Tests, lint rules and types** in the repo: make the change in a small commit, as its own slice or a note in the current one.
36
+ - **Permission rules and hooks** in `.claude/settings.json` or user settings: propose the exact JSON, and let the owner apply it. Settings files control what the agent may do, so the agent shouldn't edit its own.
37
+
38
+ Add a Log line to the active plan naming the failure and the guard.
39
+
40
+ ## Doctor
41
+
42
+ `jig doctor` reports gaps in a repo's harness and changes nothing. It checks:
43
+ - for a one-command verify
44
+ - for an empty-catch lint rule
45
+ - whether `.env` and credential files are readable without a deny rule
46
+ - whether `.claude/settings.json` and `.mcp.json` need reading before you trust the repo
47
+ - for a secret scanner in CI
48
+ - for lockfile drift
49
+
50
+ Run it, then turn each gap the owner cares about into a slice or a guard. Treat a repo you didn't write as untrusted: read its `.claude/` and `.mcp.json` before running an agent in it.
51
+
52
+ ## After an incident
53
+
54
+ Write a short blameless postmortem covering:
55
+ - what happened
56
+ - the timeline
57
+ - the cause
58
+ - whether AI-written code or an agent action was involved
59
+ - the guard added for each cause
60
+
61
+ Put it where the repo keeps such documents, or in `docs/postmortems/`. Each cause gets a guard from step 2.
@@ -0,0 +1,104 @@
1
+ ---
2
+ name: plan
3
+ description: Plans engineering work before code is written, sized to the task. A one-file fix gets a few lines in chat. Larger or riskier work gets a short plan file the owner can approve, with slices, executable acceptance checks and a fresh-context review. Use whenever an engineering task is being planned or started, at any size, such as building, adding, changing, fixing, migrating, integrating or refactoring code, or when asked how to approach a change. Not for answering questions, explaining code, reviewing a diff, or debugging an error whose cause is unknown; find the cause first, then plan the fix.
4
+ allowed-tools: Read Glob Grep Bash(jig lint:*) Bash(jig status:*) Bash(jig new:*) Bash(git log:*) Bash(git status:*) Bash(git diff:*) Bash(git shortlog:*)
5
+ argument-hint: what to build or change
6
+ ---
7
+
8
+ # Plan
9
+
10
+ Goal: $ARGUMENTS (if empty, use the latest request in the conversation).
11
+
12
+ A plan exists for two readers. The owner approves its short top half, and the agent that builds it follows the rest. Write for those two readers only. The repo already describes itself, so don't restate it. Nobody reads padding, and a bad plan does worse than no plan.
13
+
14
+ Reference files live in `${CLAUDE_PLUGIN_ROOT}/references/`. Read each one only when its step needs it.
15
+
16
+ ## 1. Frame
17
+
18
+ Write the outcome in one sentence a person could check: what is true for the user, or for the code, when this is done.
19
+
20
+ Then check the request for ambiguity as a separate step, before planning. Models are poor at telling a clear request from an underspecified one, and a separate check closes most of that gap. List what you don't know, and sort each item:
21
+
22
+ - **Changes the plan, and only the owner knows it** (which behaviour they want, a constraint outside the repo, a one-way door's direction): ask it.
23
+ - **Changes the plan, and the repo can answer it:** look it up in step 2 instead of asking.
24
+ - **Doesn't change the plan:** make the call and record it under Assumptions.
25
+
26
+ Ask everything in the first group together, in one AskUserQuestion call when it's available, with your recommended answer first. If nothing is in that group, don't ask. If the owner said to proceed without questions, record the first group as assumptions too, except anything destructive or irreversible, which still needs a yes.
27
+
28
+ ## 2. Survey
29
+
30
+ Read the code the change will touch before deciding anything:
31
+
32
+ - **Existing helpers, patterns and libraries to reuse.** Search before you design: AI-written code duplicates far more than it reuses, and the fix is to find what's already there.
33
+ - **The repo's verify commands** (test, typecheck, lint) and how long they take. If there's no single command that verifies the change, the plan's first slice adds one.
34
+ - **Plans already in flight:** run `jig status`, and match the repo's plan location if it already has one.
35
+ - **Constraints recorded in the repo:** ADRs, CLAUDE.md or AGENTS.md, module ownership.
36
+
37
+ When the survey would mean reading across many files, give it to the Explore subagent and keep its conclusions, not its file dumps. For a repo with several active authors, run `git shortlog -sn --since=90.days`. More than one author means team mode: read `references/team.md`.
38
+
39
+ ## 3. Size
40
+
41
+ Pick the tier using `references/sizing.md`. In short:
42
+
43
+ - **Tier 0:** a reversible change that one command proves gets five lines in chat and no file.
44
+ - **Brief:** several files, all reversible.
45
+ - **Full:** any one-way door, new dependency, auth or data path, more than three slices, or work spanning sessions.
46
+ - **Program:** work that can't be checked as one plan.
47
+
48
+ When unsure, take the smaller tier and escalate when a signal appears.
49
+
50
+ **Tier 0:** write the four-line plan from `references/sizing.md`, then do the work. Stop here.
51
+
52
+ ## 4. Draft
53
+
54
+ Run `jig new <slug> --tier <tier> --title "<title>"`. It writes the skeleton with the baseline commit. Fill it in following `references/plan-format.md`, which `jig lint` enforces.
55
+
56
+ What matters most, and why:
57
+
58
+ - **Done when** lists commands or check IDs. "It works" can't fail, but a command can.
59
+ - **Decisions** each give a reason, and name the alternative you rejected when one was real. Consider deleting or changing existing code before adding new code, because people and models both overlook the subtractive fix. Mark one-way doors `[one-way]`: schema and partition keys, public API contracts, the auth model, data deletion, production or infrastructure changes, new runtime dependencies, scope changes.
60
+ - **Out of scope** holds only what a reader would otherwise assume is included. Don't write filler to reach a count.
61
+ - **Questions** holds only what the owner must answer. Answer everything else yourself.
62
+ - **Slices** are vertical, fit one session, and end with checks green and a commit. Each lists the files it may touch.
63
+ - **Checks** come from the spec, written before the code. A check that restates what the code does catches nothing. Choose kinds by risk using `references/failure-modes.md`:
64
+ - acceptance examples for behaviour
65
+ - `property` where a rule has an invariant
66
+ - `mutation` on core logic at the full tier
67
+ - `perf` with a threshold on hot paths
68
+ - `security` on auth and input
69
+ - **Risks** say how you'd notice each one and what you'd do instead. Don't score them.
70
+ - **No time estimates.** They are unreliable, and they turn into deadlines. Scope (slices, files, checks) is the measure.
71
+
72
+ Read `references/fundamentals.md` for the areas the change touches (concurrency, databases, networking, distributed systems, performance, design). Read `references/security.md` when it touches auth, input, secrets, dependencies, MCP or production. Read `references/safe-change.md` when it changes something people already use. Read `references/mechanisms.md` when a requirement must keep holding after the work is done; it may belong in a hook, test or lint rule rather than in prose.
73
+
74
+ When a slice changes UI and the loupe skill is available, add a loupe review of the affected screens to that slice's done-when. When the humanizing-writing skill is available, follow it for the human layer and for PR descriptions.
75
+
76
+ ## 5. Check
77
+
78
+ Run `jig lint <path>` and fix every error.
79
+
80
+ At the full and program tiers, and whenever a one-way door is involved, hand the plan to the `jig-reviewer` agent in plan mode. Give it the plan path and the original request, not your reasoning. A model grading its own plan tends to approve it, and a fresh context doesn't share your blind spots. Fix what it finds, or record in the Log why a finding doesn't apply.
81
+
82
+ ## 6. Gate
83
+
84
+ Stop for the owner when the plan has a one-way door, a destructive step, or an open question in Questions. Otherwise, approve it yourself and say so in the Log: "approved by agent; no gate applied". The owner can still read it afterwards.
85
+
86
+ - **In plan mode:** project files can't be written. Put the whole plan in the plan-mode plan file and exit plan mode for approval. Once it's approved, write `docs/plans/<slug>/PLAN.md` and `checks.json` from it before doing anything else.
87
+ - **Outside plan mode:** show the owner the human layer's outcome, one-way decisions and questions, in about ten lines, with the file path. Wait for their answer if a gate applies.
88
+
89
+ When approved, set `Status: approved`, add `Decided: <who> <date>` to each one-way decision, update `Now:`, and log the approval.
90
+
91
+ ## 7. Hand off
92
+
93
+ Tell the owner, briefly:
94
+ - the outcome
95
+ - the tier
96
+ - the slice count
97
+ - each one-way decision and how it was settled
98
+ - the plan path
99
+
100
+ If they asked for the work and not only the plan, continue with the build skill on the first slice.
101
+
102
+ ## Changing an approved plan
103
+
104
+ Edit the plan, then append a Log entry saying what changed and why. Never edit earlier Log entries; `jig lint` rejects that. If the change adds or alters a one-way door, gate it again. When the plan nears 400 lines, collapse finished slices into one Log line each.