create-agent-room 1.2.1

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.
Files changed (58) hide show
  1. package/README.md +229 -0
  2. package/bin/cli.js +186 -0
  3. package/examples/python-project/.agent-room.json +14 -0
  4. package/examples/python-project/AGENTS.md +32 -0
  5. package/examples/rust-project/.agent-room.json +12 -0
  6. package/examples/rust-project/AGENTS.md +32 -0
  7. package/lib/color.js +31 -0
  8. package/lib/fsutil.js +218 -0
  9. package/lib/init.js +660 -0
  10. package/lib/lint-sessions.js +278 -0
  11. package/lib/metrics.js +190 -0
  12. package/lib/pr.js +176 -0
  13. package/lib/prompt.js +20 -0
  14. package/lib/session-utils.js +213 -0
  15. package/lib/sync.js +138 -0
  16. package/lib/validate.js +179 -0
  17. package/package.json +48 -0
  18. package/templates/.agent-room/anti-patterns.md +22 -0
  19. package/templates/.agent-room/coordination/handoff-protocol.md +60 -0
  20. package/templates/.agent-room/coordination/scope-boundaries.md +57 -0
  21. package/templates/.agent-room/coordination/session-log-format.md +62 -0
  22. package/templates/.agent-room/decisions.md +17 -0
  23. package/templates/.agent-room/guardrails.json +23 -0
  24. package/templates/.agent-room/guardrails.md +56 -0
  25. package/templates/.agent-room/principles.md +306 -0
  26. package/templates/.agent-room/sessions/.gitkeep +4 -0
  27. package/templates/.agent-room/skills/brainstorming.md +64 -0
  28. package/templates/.agent-room/skills/closing-the-loop.md +67 -0
  29. package/templates/.agent-room/skills/systematic-debugging.md +85 -0
  30. package/templates/.agent-room/skills/test-driven-development.md +100 -0
  31. package/templates/.agent-room/skills/verification-before-completion.md +56 -0
  32. package/templates/.agent-room/skills/writing-plans.md +87 -0
  33. package/templates/.agent-room/workflow-classifier.md +127 -0
  34. package/templates/AGENTS.md.tmpl +85 -0
  35. package/templates/adapters/CLAUDE.md.tmpl +38 -0
  36. package/templates/adapters/claude-hooks/close-the-loop-check.js +96 -0
  37. package/templates/adapters/clinerules.tmpl +14 -0
  38. package/templates/adapters/codexrules.tmpl +45 -0
  39. package/templates/adapters/cursorrules.tmpl +14 -0
  40. package/templates/adapters/git-hooks/guardrails-check.js +140 -0
  41. package/templates/adapters/git-hooks/pre-commit.tmpl +43 -0
  42. package/templates/adapters/windsurfrules.tmpl +14 -0
  43. package/templates/docs/plans/.gitkeep +0 -0
  44. package/templates/skill-packs/api-design/api-design.md +152 -0
  45. package/templates/skill-packs/code-review/code-review.md +113 -0
  46. package/templates/skill-packs/database/database-migrations.md +123 -0
  47. package/templates/skill-packs/documentation/documentation.md +155 -0
  48. package/templates/skill-packs/observability/observability.md +128 -0
  49. package/templates/skill-packs/performance/performance-optimization.md +150 -0
  50. package/templates/skill-packs/release/release-management.md +145 -0
  51. package/templates/skill-packs/security/security-principles.md +127 -0
  52. package/templates/skill-packs/testing/integration-testing.md +127 -0
  53. package/templates/stacks/python/.agent-room/skills/python-testing.md +59 -0
  54. package/templates/stacks/python/AGENTS.md.tmpl +35 -0
  55. package/templates/stacks/react/.agent-room/skills/react-component-testing.md +76 -0
  56. package/templates/stacks/react/AGENTS.md.tmpl +37 -0
  57. package/templates/stacks/typescript/.agent-room/skills/typescript-testing.md +63 -0
  58. package/templates/stacks/typescript/AGENTS.md.tmpl +36 -0
@@ -0,0 +1,85 @@
1
+ ---
2
+ name: systematic-debugging
3
+ description: "Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes."
4
+ ---
5
+
6
+ # Systematic Debugging
7
+
8
+ ## Overview
9
+
10
+ Random fixes waste time and create new bugs. Quick patches mask the
11
+ underlying issue.
12
+
13
+ **Core principle:** always find the root cause before attempting a fix.
14
+ Symptom fixes are failure.
15
+
16
+ ## The iron law
17
+
18
+ ```
19
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
20
+ ```
21
+
22
+ **Especially when:** under time pressure, "just one quick fix" seems
23
+ obvious, you've already tried multiple fixes, or you don't fully understand
24
+ the issue yet. None of these are reasons to skip investigation — they're
25
+ exactly when guessing gets expensive.
26
+
27
+ ## The four phases
28
+
29
+ ### Phase 1: Root cause investigation
30
+
31
+ 1. **Read error messages and stack traces completely** — line numbers,
32
+ file paths, error codes, not just the first line.
33
+ 2. **Reproduce consistently** — exact steps, every time. Not reproducible?
34
+ Gather more data, don't guess.
35
+ 3. **Check recent changes** — git diff, recent commits, new dependencies,
36
+ config or environment differences.
37
+ 4. **In multi-component systems, gather evidence at each boundary** before
38
+ proposing fixes: log what enters/exits each component, verify
39
+ config/env propagation, check state at each layer. Run once, see *where*
40
+ it breaks, then investigate that specific component.
41
+ 5. **Trace data backward** when the error is deep in a call stack: where
42
+ did the bad value originate? What called this with that bad value? Keep
43
+ tracing up to the source — fix at the source, not at the symptom.
44
+
45
+ ### Phase 2: Pattern analysis
46
+
47
+ - Find working examples of similar code in the same codebase.
48
+ - If implementing a known pattern, read the reference completely — not a
49
+ skim.
50
+ - List every difference between the working and broken case, however small.
51
+ - Understand the dependencies, config, and assumptions involved.
52
+
53
+ ### Phase 3: Hypothesis and testing
54
+
55
+ - State one hypothesis clearly: "I think X is the root cause because Y."
56
+ - Test it with the smallest possible change — one variable at a time.
57
+ - Worked? Move to Phase 4. Didn't work? Form a *new* hypothesis — don't
58
+ stack another fix on top.
59
+ - Genuinely don't know? Say so explicitly rather than guessing.
60
+
61
+ ### Phase 4: Implementation
62
+
63
+ 1. Create a failing test that reproduces the bug (see
64
+ `.agent-room/skills/test-driven-development.md`).
65
+ 2. Implement a single fix addressing the root cause — one change, no
66
+ bundled refactoring.
67
+ 3. Verify: test passes, no other tests broke, the original issue is
68
+ actually resolved.
69
+ 4. **If the fix doesn't work, stop and count attempts.** Fewer than 3:
70
+ return to Phase 1 with the new information. **3 or more failed fixes
71
+ means the architecture is probably wrong, not the fix** — stop and
72
+ question the pattern itself rather than attempting fix #4.
73
+
74
+ ## Red flags — stop and return to Phase 1
75
+
76
+ "Quick fix for now, investigate later" · "just try changing X" · "skip the
77
+ test, I'll verify manually" · "it's probably X" · proposing a fix before
78
+ tracing data flow · "one more attempt" after 2+ failures · each fix
79
+ revealing a new problem somewhere else.
80
+
81
+ ## When investigation truly finds no root cause
82
+
83
+ Document what was investigated, implement appropriate handling (retry,
84
+ timeout, clear error message), add logging for next time. This is rare —
85
+ most "no root cause" conclusions are incomplete investigation.
@@ -0,0 +1,100 @@
1
+ ---
2
+ name: test-driven-development
3
+ description: "Use when implementing any feature or bugfix, before writing implementation code."
4
+ ---
5
+
6
+ # Test-Driven Development (TDD)
7
+
8
+ ## Overview
9
+
10
+ Write the test first. Watch it fail. Write minimal code to pass.
11
+
12
+ **Core principle:** if you didn't watch the test fail, you don't know if it
13
+ tests the right thing.
14
+
15
+ ## When to use
16
+
17
+ **Always:** new features, bug fixes, refactoring, behavior changes.
18
+
19
+ **Exceptions (ask the maintainer first):** throwaway prototypes, generated
20
+ code, configuration files.
21
+
22
+ Thinking "skip TDD just this once"? That's rationalization — stop.
23
+
24
+ ## The iron law
25
+
26
+ ```
27
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
28
+ ```
29
+
30
+ Wrote code before the test? Delete it. Don't keep it "as reference," don't
31
+ adapt it while writing the test, don't look at it. Implement fresh from
32
+ tests.
33
+
34
+ ## Red-Green-Refactor
35
+
36
+ ```
37
+ RED: write one minimal failing test
38
+ -> verify it fails for the right reason (not a typo, not existing behavior)
39
+ GREEN: write the minimal code to pass
40
+ -> verify it passes, and nothing else broke
41
+ REFACTOR: clean up, keep tests green, no new behavior
42
+ -> next failing test
43
+ ```
44
+
45
+ ### RED — write a failing test
46
+
47
+ One behavior, clear name, real code (mock only if unavoidable).
48
+
49
+ Good: `test('retries failed operations 3 times', ...)` — tests real behavior.
50
+ Bad: `test('retry works', ...)` with a mock asserting call count — tests the
51
+ mock, not the code.
52
+
53
+ ### Verify RED — mandatory, never skip
54
+
55
+ Run the test command. Confirm: it fails (not errors), the failure message
56
+ is the expected one, and it fails because the feature is missing — not
57
+ because of a typo. If it passes, you're testing existing behavior — fix the
58
+ test.
59
+
60
+ ### GREEN — minimal code
61
+
62
+ Write just enough to pass. Don't add options, config, or "while I'm here"
63
+ improvements the test doesn't require (YAGNI).
64
+
65
+ ### Verify GREEN — mandatory
66
+
67
+ Run the test command again. Confirm it passes and nothing else broke, with
68
+ clean output (no stray errors/warnings).
69
+
70
+ ### REFACTOR
71
+
72
+ Remove duplication, improve names, extract helpers — only after green, and
73
+ only while staying green.
74
+
75
+ ## Why order matters
76
+
77
+ - **Tests written after code pass immediately** — passing immediately proves
78
+ nothing about whether the test would have caught a real bug.
79
+ - **Manual testing isn't a substitute** — no record, can't re-run, easy to
80
+ forget edge cases under pressure.
81
+ - **"I already spent hours on this, deleting is wasteful"** is sunk-cost
82
+ reasoning — the time is gone either way; the choice is rewrite-with-tests
83
+ (high confidence) vs. keep-untested (technical debt from day one).
84
+
85
+ ## Verification checklist before calling work done
86
+
87
+ - [ ] Every new function/method has a test
88
+ - [ ] Watched each test fail before implementing
89
+ - [ ] Each test failed for the expected reason
90
+ - [ ] Wrote minimal code to pass each test
91
+ - [ ] All tests pass, output is clean
92
+ - [ ] Edge cases and error paths are covered
93
+
94
+ Can't check every box? TDD was skipped somewhere — go back.
95
+
96
+ ## Debugging integration
97
+
98
+ Found a bug? Write a failing test that reproduces it first, then follow the
99
+ same red-green-refactor cycle. Never fix a bug without a regression test.
100
+ See `.agent-room/skills/systematic-debugging.md` for root-causing it first.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: verification-before-completion
3
+ description: "Use before claiming work is complete, fixed, or passing - before committing or opening a PR. Evidence before assertions, always."
4
+ ---
5
+
6
+ # Verification Before Completion
7
+
8
+ ## Overview
9
+
10
+ Claiming work is complete without verification is dishonesty, not
11
+ efficiency.
12
+
13
+ **Core principle:** evidence before claims, always.
14
+
15
+ ## The iron law
16
+
17
+ ```
18
+ NO COMPLETION CLAIMS WITHOUT FRESH VERIFICATION EVIDENCE
19
+ ```
20
+
21
+ If you haven't run the verification command in this turn, you cannot claim
22
+ it passes.
23
+
24
+ ## The gate
25
+
26
+ ```
27
+ Before claiming any status or expressing satisfaction:
28
+ 1. IDENTIFY what command actually proves the claim
29
+ 2. RUN the full command, fresh
30
+ 3. READ the full output — exit code, failure count, warnings
31
+ 4. Does the output confirm the claim?
32
+ no -> state the actual status, with evidence
33
+ yes -> state the claim, with evidence
34
+ ```
35
+
36
+ ## Common failures
37
+
38
+ | Claim | Requires | Not sufficient |
39
+ | --- | --- | --- |
40
+ | Tests pass | test command output: 0 failures | "should pass", a previous run |
41
+ | Lint clean | linter output: 0 errors | partial check |
42
+ | Build succeeds | build command: exit 0 | linter passing |
43
+ | Bug fixed | test of the original symptom passes | code changed, assumed fixed |
44
+ | Regression test works | red-green cycle actually verified | passes once |
45
+ | Agent/subtask completed | diff shows the actual changes | "agent reported success" |
46
+
47
+ ## Red flags — stop
48
+
49
+ Using "should", "probably", "seems to" · expressing satisfaction before
50
+ verifying ("done!", "perfect!") · about to commit/push/open a PR without
51
+ running anything · trusting a sub-agent's self-report instead of checking
52
+ the diff · "just this once."
53
+
54
+ ## The bottom line
55
+
56
+ Run the command. Read the output. Then make the claim. No shortcuts.
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: writing-plans
3
+ description: "Use when you have an approved design or requirements for a multi-step task, before touching code."
4
+ ---
5
+
6
+ # Writing Plans
7
+
8
+ ## Overview
9
+
10
+ Turn an approved design into an implementation plan, written as if the
11
+ executor (a fresh agent session, a teammate, or future-you) has zero context
12
+ on this codebase. Document exactly which files to touch, the code, the
13
+ tests, and how to verify each step. DRY. YAGNI. TDD. Frequent commits.
14
+
15
+ **Save plans to:** `docs/plans/YYYY-MM-DD-<feature-name>.md`
16
+
17
+ ## Bite-sized task granularity
18
+
19
+ Each step is one action, roughly 2-5 minutes:
20
+ - "Write the failing test" — step
21
+ - "Run it, confirm it fails for the right reason" — step
22
+ - "Write the minimal code to pass" — step
23
+ - "Run it, confirm it passes" — step
24
+ - "Commit" — step
25
+
26
+ ## Plan document header
27
+
28
+ Every plan starts with:
29
+
30
+ ```markdown
31
+ # [Feature Name] Implementation Plan
32
+
33
+ **Goal:** [one sentence describing what this builds]
34
+ **Architecture:** [2-3 sentences about the approach]
35
+ **Tech stack:** [key technologies/libraries]
36
+
37
+ ---
38
+ ```
39
+
40
+ ## Task structure
41
+
42
+ ````markdown
43
+ ### Task N: [Component Name]
44
+
45
+ **Files:**
46
+ - Create: `exact/path/to/file.ext`
47
+ - Modify: `exact/path/to/existing.ext:123-145`
48
+ - Test: `tests/exact/path/to/test.ext`
49
+
50
+ **Step 1: Write the failing test**
51
+ [complete test code, not "add validation"]
52
+
53
+ **Step 2: Run test to verify it fails**
54
+ Run: `<exact command>`
55
+ Expected: FAIL with "<exact message>"
56
+
57
+ **Step 3: Write minimal implementation**
58
+ [complete code]
59
+
60
+ **Step 4: Run test to verify it passes**
61
+ Run: `<exact command>`
62
+ Expected: PASS
63
+
64
+ **Step 5: Commit**
65
+ ```bash
66
+ git add <files>
67
+ git commit -m "<message>"
68
+ ```
69
+ ````
70
+
71
+ ## Remember
72
+
73
+ - Exact file paths always.
74
+ - Complete code in the plan, never "add validation" as a placeholder.
75
+ - Exact commands with expected output, not "run the tests."
76
+ - DRY, YAGNI, TDD, frequent commits.
77
+
78
+ ## Execution
79
+
80
+ Once the plan is saved, either:
81
+ 1. **Work through it task-by-task in this session**, verifying each step
82
+ before moving to the next (see `.agent-room/skills/test-driven-development.md`
83
+ and `.agent-room/skills/verification-before-completion.md`), or
84
+ 2. **Hand the plan file to a fresh agent session** to execute, if you want a
85
+ clean context with no accumulated assumptions from the design discussion.
86
+
87
+ Either way: one task at a time, verify before moving on, commit frequently.
@@ -0,0 +1,127 @@
1
+ # Workflow Classifier
2
+
3
+ Not all work deserves the same process. Classify before loading process —
4
+ over-process wastes time, under-process builds the wrong thing.
5
+
6
+ ## Quick classifier
7
+
8
+ | Work Type | Use it for | PRD | Architecture | TDD | Time |
9
+ | --- | --- | --- | --- | --- | --- |
10
+ | Bug | Something broke | None | None | Fix + regression test | Hours |
11
+ | Enhancement | Small change on existing rails | Light | Light | Yes | Days |
12
+ | Feature | New bounded capability | Yes | Yes | Full | Weeks |
13
+ | Product | New system or unclear scope | Deep | Extensive | Full + spikes | Months |
14
+
15
+ ## Decision tree
16
+
17
+ ```
18
+ Did something break?
19
+ yes -> Bug Flow
20
+ no
21
+ Does similar code/pattern already exist in this repo?
22
+ yes -> Enhancement Flow
23
+ no
24
+ Is the scope clear and bounded?
25
+ yes -> Feature Flow
26
+ no -> Product Flow
27
+ ```
28
+
29
+ Stop as soon as one answer is clear. Ask in this order:
30
+ 1. Did something break?
31
+ 2. Am I extending an existing pattern?
32
+ 3. Can I define "done" right now?
33
+ 4. If not, am I still discovering the problem?
34
+
35
+ ## Worked examples
36
+
37
+ ### "Fix: login button returns 500 on Safari"
38
+ - Did something break? Yes — it worked before, now it doesn't.
39
+ - **Classification: Bug.**
40
+ - Process: Reproduce on Safari, read the server logs, find the root cause
41
+ (not the symptom), write a regression test, smallest fix, note why it
42
+ slipped through in `anti-patterns.md`. Hours.
43
+
44
+ ### "Add dark mode to the settings page"
45
+ - Did something break? No.
46
+ - Does similar code exist? Yes — there's already a theme toggle in the
47
+ header component and CSS custom properties for colors in `theme.css`.
48
+ - **Classification: Enhancement.**
49
+ - Process: Light PRD (one paragraph: "extend the existing theme system to
50
+ settings page, using the same CSS custom properties"), find the closest
51
+ prior example (`Header.tsx` theme toggle), TDD the new toggle, 1-2 days.
52
+
53
+ ### "Support webhook notifications for order status changes"
54
+ - Did something break? No.
55
+ - Does similar code exist? No — there's no webhook infrastructure, no
56
+ event system, no retry queue.
57
+ - Is the scope clear? Yes — we know exactly which events trigger webhooks,
58
+ the payload shape, and the delivery guarantees we need.
59
+ - **Classification: Feature.**
60
+ - Process: Full brainstorm (delivery guarantees? retry policy? signature
61
+ verification?), design doc, architecture review, TDD, 1-2 weeks.
62
+
63
+ ### "We need to support multi-tenant data isolation"
64
+ - Did something break? No.
65
+ - Does similar code exist? No — the app is single-tenant.
66
+ - Is the scope clear? Partially — we know what isolation means, but the
67
+ migration strategy, tenant resolution mechanism, and query scoping
68
+ approach all need design. We're still discovering the problem.
69
+ - **Classification: Product.**
70
+ - Process: Define the problem before the feature list. Write key hypotheses
71
+ ("row-level security vs. schema-per-tenant"). Spike the risky assumptions.
72
+ Build the smallest useful proof of concept. Learn and iterate. Months.
73
+
74
+ ## Misclassification signals
75
+
76
+ You classified wrong if any of these are true:
77
+
78
+ | Signal | What it means |
79
+ | --- | --- |
80
+ | A "Bug" fix requires changing more than 3 files | It's probably an Enhancement or Feature — the root cause is structural, not a local defect. |
81
+ | An "Enhancement" keeps revealing new unknowns | It's actually a Feature — you can't define "done" because the scope keeps growing. |
82
+ | A "Feature" has been in progress for 2+ months | It's actually a Product — the scope was never bounded, and you're discovering requirements as you build. |
83
+ | A "Product" has a perfectly clear scope and takes 2 weeks | It was a Feature all along — you over-classified and loaded unnecessary process. |
84
+ | Time spent dramatically exceeds the budget below | The classification, not the estimate, is probably wrong. Re-classify rather than push through. |
85
+
86
+ **The fix is always the same:** stop, re-classify, adjust the process.
87
+ Don't push through with the wrong process — that's how Bug fixes become
88
+ multi-week refactors and Features become death marches.
89
+
90
+ ## Bug Flow (hours)
91
+ Reproduce -> Diagnose (root cause, not symptom) -> Write the regression test
92
+ first -> Smallest fix that passes -> Run the relevant checks -> Note why it
93
+ slipped through (append to `.agent-room/anti-patterns.md`).
94
+
95
+ Do not load: PRD files, architecture exploration, spikes.
96
+
97
+ ## Enhancement Flow (days)
98
+ Confirm it fits existing rails -> short PRD (a paragraph is fine) -> find the
99
+ closest prior example in the codebase -> TDD -> quick review and ship.
100
+
101
+ Rule of thumb: if you can describe it as "do X like we already do Y," it's an
102
+ enhancement. If you can't find a Y, it's a feature.
103
+
104
+ ## Feature Flow (weeks)
105
+ Write the first design from the user journey -> let architecture discoveries
106
+ tighten/simplify the design (don't treat draft 1 as sacred) -> TDD against the
107
+ final shape -> review -> observe after shipping.
108
+
109
+ Use the `brainstorming` -> `writing-plans` -> TDD chain in `.agent-room/skills/`
110
+ for this.
111
+
112
+ ## Product Flow (months)
113
+ Define the problem before the feature list -> write the key hypotheses ->
114
+ spike the risky assumptions -> build the smallest useful MVP -> learn from
115
+ reality and loop (iterate or pivot).
116
+
117
+ ## Time budget as a signal
118
+
119
+ | Work Type | Design | Build | Review | Total |
120
+ | --- | --- | --- | --- | --- |
121
+ | Bug | 0 | ~2h | 30m | hours |
122
+ | Enhancement | 30m | ~4h | 1h | 1-2 days |
123
+ | Feature | 4-8h | 16h+ | 4h | 1-2 weeks |
124
+ | Product | 8h+ | 40h+ | 8h+ | 4+ weeks |
125
+
126
+ If real work keeps blowing past the expected budget, the classification —
127
+ not the estimate — is probably wrong. Re-classify rather than push through.
@@ -0,0 +1,85 @@
1
+ # Agent Instructions — {{PROJECT_NAME}}
2
+
3
+ This file is the entry point for any AI coding agent (Claude Code, Codex,
4
+ Cursor, etc.) working in this repository. Tool-specific files (`CLAUDE.md`,
5
+ `.cursor/rules`, ...) are thin pointers back to this file plus their own
6
+ loading mechanics — the actual content lives here and in `.agent-room/`.
7
+
8
+ ## The First 5 Minutes
9
+
10
+ When you first enter this repository or start a new task, **stop and read**.
11
+ Do not immediately start writing code.
12
+
13
+ 1. **Check coordination state:** Are there other agents working? Check open
14
+ PRs, issue assignments, or the `.agent-room/sessions/` directory.
15
+ Read `.agent-room/coordination/handoff-protocol.md` if you are picking
16
+ up someone else's work.
17
+ 2. **Classify the work:** Use `.agent-room/workflow-classifier.md`. Don't
18
+ apply Feature-weight process to a one-line bug fix, and don't skip design
19
+ for a "simple" feature.
20
+ 3. **Check guardrails:** Review `.agent-room/guardrails.md`. Ensure your
21
+ planned work does not touch protected paths or require human approval
22
+ without asking first.
23
+ 4. **Review past decisions:** Read `.agent-room/anti-patterns.md` and
24
+ `.agent-room/decisions.md` to understand *why* the codebase is structured
25
+ this way, and what mistakes to avoid.
26
+
27
+ ## Read these before doing anything non-trivial
28
+
29
+ - [`.agent-room/principles.md`](.agent-room/principles.md) — how to get
30
+ reliable output from an LLM (context, iteration, checkpointing, tests as
31
+ spec, negative knowledge).
32
+ - [`.agent-room/guardrails.md`](.agent-room/guardrails.md) — boundaries and
33
+ constraints. Check before touching protected paths or making large changes.
34
+ - [`.agent-room/workflow-classifier.md`](.agent-room/workflow-classifier.md) —
35
+ how to size the process to the work (Bug / Enhancement / Feature / Product).
36
+ - [`.agent-room/anti-patterns.md`](.agent-room/anti-patterns.md) — things that
37
+ have already gone wrong in this project. Check before repeating a mistake;
38
+ append after fixing one.
39
+ - [`.agent-room/decisions.md`](.agent-room/decisions.md) — short log of
40
+ architecture/design decisions and why. Append when you make one that future
41
+ sessions would otherwise have to re-derive.
42
+ - [`.agent-room/skills/`](.agent-room/skills/) — procedures to follow, not
43
+ just read: `brainstorming`, `writing-plans`, `test-driven-development`,
44
+ `systematic-debugging`, `verification-before-completion`,
45
+ `closing-the-loop`.
46
+ - [`.agent-room/coordination/`](.agent-room/coordination/) — protocols for
47
+ multi-agent workflows: `handoff-protocol`, `scope-boundaries`,
48
+ `session-log-format`.
49
+
50
+ ## The default workflow
51
+
52
+ 1. **Classify the work** using `.agent-room/workflow-classifier.md`.
53
+ 2. **For anything beyond a trivial bug fix**, brainstorm before building: ask
54
+ clarifying questions, propose 2-3 approaches with trade-offs, get the
55
+ design approved, *then* write a short design note under `docs/plans/`.
56
+ 3. **Use TDD**: write the failing test first, watch it fail, write the
57
+ minimal code to pass, refactor, commit. No production code without a
58
+ failing test first.
59
+ 4. **Debug systematically**: find the root cause before proposing a fix.
60
+ Reproduce, check recent changes, gather evidence at component boundaries.
61
+ No fixes without root-cause investigation.
62
+ 5. **Verify before claiming done**: run the actual test/build/lint command in
63
+ this turn and read its output before saying "tests pass" or "fixed."
64
+ "Should work" is not evidence.
65
+ 6. **Serialize state**: Before ending your session, log your work in
66
+ `.agent-room/sessions/` according to `session-log-format.md`, and write
67
+ a handoff note if the task is incomplete.
68
+ 7. **Close the loop — before ending the turn, not after**: this is a gate,
69
+ not a suggestion. Follow `.agent-room/skills/closing-the-loop.md`. If the
70
+ turn fixed a bug, found a root cause, or made a non-obvious design call,
71
+ append it to `.agent-room/anti-patterns.md` or `.agent-room/decisions.md`
72
+ *before* claiming the task is done. If nothing qualifies, say so
73
+ explicitly rather than silently skipping the check.
74
+
75
+ ## Project-specific notes
76
+
77
+ - **Language:** {{LANGUAGE}}
78
+ - **Package Manager:** {{PACKAGE_MANAGER}}
79
+ - **Default Branch:** {{DEFAULT_BRANCH}}
80
+
81
+ Commands:
82
+ - Run tests: `{{TEST_COMMAND}}`
83
+ - Run linting: `{{LINT_COMMAND}}`
84
+
85
+ <!-- Add stack, conventions, and anything else an agent needs that isn't derivable. -->
@@ -0,0 +1,38 @@
1
+ # CLAUDE.md — {{PROJECT_NAME}}
2
+
3
+ This file is read automatically by Claude Code. The actual guidance lives in
4
+ [`AGENTS.md`](AGENTS.md) and [`.agent-room/`](.agent-room/) — read those
5
+ first, this file only adds Claude Code-specific mechanics.
6
+
7
+ ## Skills
8
+
9
+ The skills in `.agent-room/skills/` are mirrored into `.claude/skills/` so
10
+ Claude Code can discover and invoke them (`/brainstorming`,
11
+ `/writing-plans`, `/test-driven-development`, `/systematic-debugging`,
12
+ `/verification-before-completion`, `/closing-the-loop`).
13
+
14
+ `.agent-room/skills/` is the source of truth. If you edit a skill, re-run
15
+ `npx create-agent-room sync` to refresh the `.claude/skills/` copies — don't
16
+ edit the `.claude/skills/` copies directly, they'll be overwritten.
17
+
18
+ ## Closing-the-loop hook
19
+
20
+ A `Stop` hook is wired up in `.claude/settings.json`, running
21
+ `.agent-room/hooks/close-the-loop-check.js` at the end of every turn. If the
22
+ turn changed tracked files outside the agent-room scaffold but didn't touch
23
+ `.agent-room/anti-patterns.md` or `.agent-room/decisions.md`, the hook
24
+ blocks the turn from ending and explains why. This is mechanical
25
+ enforcement of `.agent-room/skills/closing-the-loop.md` — it can't judge
26
+ whether an entry is *good*, only that the check wasn't silently skipped.
27
+
28
+ The exit hatch is a one-line waiver in `decisions.md`:
29
+ `<!-- no-log: routine change, no decision or anti-pattern worth recording -->`
30
+
31
+ The hook only looks at `git status --porcelain`, so unrelated pre-existing
32
+ dirty files in the work tree will also trigger it — commit or stash them
33
+ first if that gets noisy.
34
+
35
+ ## Git rules
36
+
37
+ - Do not run `git push` unless explicitly asked.
38
+ - Do not amend or rewrite history on shared branches without being asked.
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /*
5
+ * Claude Code Stop hook: mechanically enforces .agent-room/skills/closing-the-loop.md.
6
+ *
7
+ * Runs at the end of every turn. If tracked, uncommitted changes touch files
8
+ * outside the agent-room scaffold but neither .agent-room/anti-patterns.md
9
+ * nor .agent-room/decisions.md was also touched, it blocks the turn from
10
+ * ending (exit code 2) and explains why via stderr, which Claude Code feeds
11
+ * back to the model as the reason it can't stop yet.
12
+ *
13
+ * Exit hatch: touch either log file - a real entry, or a one-line waiver
14
+ * comment - and the check passes. See closing-the-loop.md for the format.
15
+ *
16
+ * Limitations (by design, to stay simple):
17
+ * - Only looks at `git status --porcelain` since the last commit, not since
18
+ * the start of this turn. Pre-existing unrelated dirty changes in the work
19
+ * tree will also trigger this - commit or stash them first if that's noisy.
20
+ * - Treats any file rename touching scaffold paths as a non-scaffold change
21
+ * (rare, harmless false positive).
22
+ */
23
+
24
+ const { execSync } = require('child_process');
25
+ const fs = require('fs');
26
+ const path = require('path');
27
+
28
+ function sh(cmd) {
29
+ try {
30
+ return execSync(cmd, { cwd: process.cwd(), stdio: ['ignore', 'pipe', 'ignore'] }).toString();
31
+ } catch (err) {
32
+ return '';
33
+ }
34
+ }
35
+
36
+ function isGitRepo() {
37
+ return sh('git rev-parse --is-inside-work-tree 2>/dev/null').trim() === 'true';
38
+ }
39
+
40
+ const SCAFFOLD_PREFIXES = [
41
+ '.agent-room/',
42
+ 'docs/plans/',
43
+ '.claude/skills/',
44
+ '.claude/settings.json',
45
+ '.cursor/rules/',
46
+ ];
47
+ const SCAFFOLD_FILES = ['AGENTS.md', 'CLAUDE.md'];
48
+
49
+ function isScaffoldPath(p) {
50
+ if (SCAFFOLD_FILES.includes(p)) return true;
51
+ // Bidirectional: p itself under a scaffold prefix (normal case), OR p is an
52
+ // ancestor directory of a scaffold prefix (git collapses an untracked dir
53
+ // with no other tracked siblings into a single porcelain line, e.g. a
54
+ // brand-new ".claude/" with nothing else in it yet shows as "?? .claude/").
55
+ return SCAFFOLD_PREFIXES.some((prefix) => p.startsWith(prefix) || prefix.startsWith(p));
56
+ }
57
+
58
+ function isLogPath(p) {
59
+ return p === '.agent-room/anti-patterns.md' || p === '.agent-room/decisions.md';
60
+ }
61
+
62
+ function main() {
63
+ const cwd = process.cwd();
64
+
65
+ if (!fs.existsSync(path.join(cwd, '.agent-room'))) {
66
+ process.exit(0); // not a scaffolded project
67
+ }
68
+ if (!isGitRepo()) {
69
+ process.exit(0); // no git history to check against
70
+ }
71
+
72
+ const lines = sh('git status --porcelain').split('\n').filter(Boolean);
73
+ const changedPaths = lines.map((line) => line.slice(3).trim());
74
+
75
+ const sourceChanges = changedPaths.filter((p) => !isScaffoldPath(p));
76
+ const logTouched = changedPaths.some(isLogPath);
77
+
78
+ if (sourceChanges.length === 0 || logTouched) {
79
+ process.exit(0);
80
+ }
81
+
82
+ const sample = sourceChanges.slice(0, 5).join(', ') + (sourceChanges.length > 5 ? ', ...' : '');
83
+ process.stderr.write(
84
+ 'Closing-the-loop check failed: this turn changed ' + sourceChanges.length +
85
+ ' file(s) outside the agent-room scaffold (' + sample + '), but neither ' +
86
+ '.agent-room/anti-patterns.md nor .agent-room/decisions.md was touched.\n\n' +
87
+ 'Follow .agent-room/skills/closing-the-loop.md before finishing this turn:\n' +
88
+ '- If this fixed a bug or found a root cause, append an entry to anti-patterns.md.\n' +
89
+ '- If this made a non-obvious design/architecture call, append an entry to decisions.md.\n' +
90
+ '- If genuinely neither applies, add a one-line waiver to decisions.md instead:\n' +
91
+ ' <!-- no-log: routine change, no decision or anti-pattern worth recording -->\n'
92
+ );
93
+ process.exit(2);
94
+ }
95
+
96
+ main();