@fernado03/zoo-flow 0.9.1 → 0.10.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.
Files changed (60) hide show
  1. package/README.md +113 -81
  2. package/bin/zoo-flow.js +444 -134
  3. package/package.json +3 -3
  4. package/templates/claude-code/.claude/commands/caveman.md +26 -0
  5. package/templates/claude-code/.claude/commands/commit-and-document.md +27 -0
  6. package/templates/claude-code/.claude/commands/diagnose.md +27 -0
  7. package/templates/claude-code/.claude/commands/feature.md +46 -0
  8. package/templates/claude-code/.claude/commands/fix.md +45 -0
  9. package/templates/claude-code/.claude/commands/grill-me.md +27 -0
  10. package/templates/claude-code/.claude/commands/grill-with-docs.md +27 -0
  11. package/templates/claude-code/.claude/commands/handoff.md +27 -0
  12. package/templates/claude-code/.claude/commands/improve-codebase-architecture.md +27 -0
  13. package/templates/claude-code/.claude/commands/prototype.md +27 -0
  14. package/templates/claude-code/.claude/commands/refactor.md +46 -0
  15. package/templates/claude-code/.claude/commands/review.md +27 -0
  16. package/templates/claude-code/.claude/commands/scaffold-context.md +27 -0
  17. package/templates/claude-code/.claude/commands/setup-matt-pocock-skills.md +27 -0
  18. package/templates/claude-code/.claude/commands/tdd.md +27 -0
  19. package/templates/claude-code/.claude/commands/teach.md +27 -0
  20. package/templates/claude-code/.claude/commands/to-issues.md +27 -0
  21. package/templates/claude-code/.claude/commands/to-prd.md +27 -0
  22. package/templates/claude-code/.claude/commands/triage.md +27 -0
  23. package/templates/claude-code/.claude/commands/tweak.md +27 -0
  24. package/templates/claude-code/.claude/commands/update-docs.md +27 -0
  25. package/templates/claude-code/.claude/commands/verify.md +27 -0
  26. package/templates/claude-code/.claude/commands/write-a-skill.md +27 -0
  27. package/templates/claude-code/.claude/commands/zoom-out.md +27 -0
  28. package/templates/claude-code/.claude/skills/engineering/commit-and-document/SKILL.md +37 -0
  29. package/templates/claude-code/.claude/skills/engineering/diagnose/SKILL.md +102 -0
  30. package/templates/claude-code/.claude/skills/engineering/explore/SKILL.md +61 -0
  31. package/templates/claude-code/.claude/skills/engineering/feature/SKILL.md +66 -0
  32. package/templates/claude-code/.claude/skills/engineering/fix/SKILL.md +59 -0
  33. package/templates/claude-code/.claude/skills/engineering/grill-with-docs/SKILL.md +35 -0
  34. package/templates/claude-code/.claude/skills/engineering/improve-codebase-architecture/SKILL.md +39 -0
  35. package/templates/claude-code/.claude/skills/engineering/prototype/SKILL.md +34 -0
  36. package/templates/claude-code/.claude/skills/engineering/refactor/SKILL.md +59 -0
  37. package/templates/claude-code/.claude/skills/engineering/review/SKILL.md +117 -0
  38. package/templates/claude-code/.claude/skills/engineering/scaffold-context/SKILL.md +44 -0
  39. package/templates/claude-code/.claude/skills/engineering/setup-matt-pocock-skills/SKILL.md +48 -0
  40. package/templates/claude-code/.claude/skills/engineering/tdd/SKILL.md +81 -0
  41. package/templates/claude-code/.claude/skills/engineering/to-issues/SKILL.md +37 -0
  42. package/templates/claude-code/.claude/skills/engineering/to-prd/SKILL.md +39 -0
  43. package/templates/claude-code/.claude/skills/engineering/triage/SKILL.md +36 -0
  44. package/templates/claude-code/.claude/skills/engineering/tweak/SKILL.md +37 -0
  45. package/templates/claude-code/.claude/skills/engineering/update-docs/SKILL.md +33 -0
  46. package/templates/claude-code/.claude/skills/engineering/verify/SKILL.md +38 -0
  47. package/templates/claude-code/.claude/skills/engineering/zoom-out/SKILL.md +34 -0
  48. package/templates/claude-code/.claude/skills/productivity/caveman/SKILL.md +24 -0
  49. package/templates/claude-code/.claude/skills/productivity/grill-me/SKILL.md +21 -0
  50. package/templates/claude-code/.claude/skills/productivity/handoff/SKILL.md +20 -0
  51. package/templates/claude-code/.claude/skills/productivity/teach/SKILL.md +116 -0
  52. package/templates/claude-code/.claude/skills/productivity/write-a-skill/SKILL.md +59 -0
  53. package/templates/claude-code/.zoo-flow/CONTEXT.md +8 -0
  54. package/templates/claude-code/.zoo-flow/START_HERE.md +28 -0
  55. package/templates/claude-code/.zoo-flow/docs/adr/0001-record-architecture-decisions.md +22 -0
  56. package/templates/claude-code/.zoo-flow/evals/no-regression-checklist.md +26 -0
  57. package/templates/claude-code/.zoo-flow/evals/routing-cases.jsonl +18 -0
  58. package/templates/claude-code/.zoo-flow/evals/routing-cases.md +211 -0
  59. package/templates/claude-code/.zoo-flow/project-profile.json +24 -0
  60. package/templates/claude-code/CLAUDE.md +237 -0
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: "Verify that changes work correctly by running tests"
3
+ argument-hint: "<what to verify>"
4
+ ---
5
+
6
+ # Verify — Test and Validation
7
+
8
+ This command runs tests and validations to verify changes work correctly.
9
+
10
+ ## Behavioral Context: Implementer
11
+
12
+ You are operating in the **Implementer profile**:
13
+ - **File access**: Full repository access (read-only during verification)
14
+ - **Scope**: Run tests, don't modify code
15
+ - **Output**: Test results and verification report
16
+
17
+ ## Procedure
18
+
19
+ Read and follow the skill file: `.claude/skills/engineering/verify/SKILL.md`
20
+
21
+ ## Expected Outcome
22
+
23
+ - All relevant tests executed
24
+ - Clear pass/fail results
25
+ - Report of any issues found
26
+
27
+ $ARGUMENTS
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: "Create a new reusable skill"
3
+ argument-hint: "<what skill to create>"
4
+ ---
5
+
6
+ # Write Skill — Skill Creation
7
+
8
+ This command creates a new reusable skill that can be referenced by other commands.
9
+
10
+ ## Behavioral Context: Implementer
11
+
12
+ You are operating in the **Implementer profile**:
13
+ - **File access**: Full repository access
14
+ - **Scope**: Create skill documentation in `.claude/skills/`
15
+ - **Output**: New skill with procedure and examples
16
+
17
+ ## Procedure
18
+
19
+ Read and follow the skill file: `.claude/skills/productivity/write-a-skill/SKILL.md`
20
+
21
+ ## Expected Outcome
22
+
23
+ - New skill created in appropriate bucket (engineering/, productivity/, misc/, personal/, in-progress/)
24
+ - Clear procedure documented
25
+ - Examples and usage guidance provided
26
+
27
+ $ARGUMENTS
@@ -0,0 +1,27 @@
1
+ ---
2
+ description: "High-level architectural overview and zoom-out"
3
+ argument-hint: "<what to overview>"
4
+ ---
5
+
6
+ # Zoom Out — Architectural Overview
7
+
8
+ This command provides a high-level architectural overview of the codebase or a specific area.
9
+
10
+ ## Behavioral Context: Architect
11
+
12
+ You are operating in the **Architect profile**:
13
+ - **File access**: Read-only for application code
14
+ - **Scope**: Understand big-picture architecture
15
+ - **Output**: Architectural overview document
16
+
17
+ ## Procedure
18
+
19
+ Read and follow the skill file: `.claude/skills/engineering/zoom-out/SKILL.md`
20
+
21
+ ## Expected Outcome
22
+
23
+ - High-level architecture diagram or description
24
+ - Key components and their relationships
25
+ - Architectural patterns and decisions identified
26
+
27
+ $ARGUMENTS
@@ -0,0 +1,37 @@
1
+ ---
2
+ name: commit-and-document
3
+ description: Commit changes and update documentation. Use after implementation is complete and verified.
4
+ ---
5
+
6
+ # Commit and Document
7
+
8
+ RULE: Never commit without explicit user approval. Never force-push.
9
+
10
+ ## Procedure
11
+
12
+ 1. Review changes using `Bash` with `git status` and `git diff`.
13
+ 2. Summarize changes for user.
14
+ 3. Ask user for approval via `AskUserQuestion`.
15
+ 4. If approved:
16
+ - Stage changes using `Bash` with `git add`.
17
+ - Commit using `Bash` with `git commit -m "message"`.
18
+ - Update relevant documentation using `Write` or `Edit`.
19
+ 5. If not approved, stop and wait for further instructions.
20
+
21
+ ## Context economy
22
+
23
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
24
+
25
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
26
+
27
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
28
+
29
+ Do not re-read unchanged files; use prior findings unless the file changed.
30
+
31
+ ## Complete
32
+
33
+ Return completion with:
34
+ - commit hash
35
+ - files changed
36
+ - documentation updated
37
+ - status (committed or waiting for approval)
@@ -0,0 +1,102 @@
1
+ ---
2
+ name: diagnose
3
+ description: Disciplined diagnosis loop for hard bugs and performance regressions. Reproduce → minimise → hypothesise → instrument → fix → regression-test. Use when user says "diagnose this" / "debug this", reports a bug, says something is broken/throwing/failing, or describes a performance regression.
4
+ ---
5
+
6
+ # Diagnose
7
+
8
+ RULE: glossary + ADRs. Skip phase only with explicit reason. DO NOT hypothesise before deterministic loop.
9
+
10
+ ## 1. Feedback loop
11
+
12
+ MUST build fast pass/fail loop. Try order:
13
+ 1. Failing test at bug-reaching seam.
14
+ 2. Curl/HTTP script via `Bash` vs dev server.
15
+ 3. CLI fixture + stdout diff via `Bash`.
16
+ 4. Headless browser: DOM/console/network assertions.
17
+ 5. Replay trace/request/payload/event log.
18
+ 6. Throwaway minimal subsystem harness.
19
+ 7. Property/fuzz loop.
20
+ 8. `git bisect run` harness via `Bash`.
21
+ 9. Differential loop: old vs new/config A vs B.
22
+ 10. HITL bash script from `scripts/hitl-loop.template.sh`.
23
+
24
+ Rules:
25
+ - MUST make loop faster/sharper/deterministic.
26
+ - Flake: run 100x, parallelise, stress, add sleeps, raise repro rate.
27
+
28
+ ## 2. Reproduce
29
+
30
+ 1. Run loop.
31
+ 2. Match symptom to report.
32
+ 3. Confirm repeatability/flake rate.
33
+ 4. Capture exact error/output/timing.
34
+ 5. DO NOT continue until reproduced.
35
+
36
+ ## 3. Hypotheses
37
+
38
+ 1. Generate 3–5 ranked falsifiable hypotheses.
39
+ 2. Format: `If {cause}, then {probe/change} will {observable result}`.
40
+ 3. Drop vague hypotheses.
41
+ 4. Show ranked list.
42
+ 5. User AFK → proceed top hypothesis.
43
+
44
+ ## 4. Instrument
45
+
46
+ 1. Map one probe to one hypothesis.
47
+ 2. Change one variable at a time.
48
+ 3. Prefer debugger/REPL.
49
+ 4. Else add targeted logs only.
50
+ 5. Tag logs `[DEBUG-xxxx]`.
51
+ 6. DO NOT log everything.
52
+ 7. Perf: baseline/profiler/query plan before logs.
53
+
54
+ ## 5. Fix + regression
55
+
56
+ **OWNER: Implementer profile** (requires source-code edits)
57
+
58
+ Delegate to implementer profile via `Agent` tool before this phase. Implementer executes:
59
+
60
+ 1. If correct seam exists, write regression test before fix.
61
+ 2. Correct seam = real call-site bug pattern.
62
+ 3. If seam shallow/missing, document architecture gap.
63
+ 4. Watch regression fail.
64
+ 5. Apply minimal fix.
65
+ 6. Watch regression pass.
66
+ 7. Rerun original loop.
67
+
68
+ Implementer does NOT return completion here — more phases remain. Continue to Phase 6.
69
+
70
+ ## 6. Cleanup
71
+
72
+ **OWNER: Implementer profile** (requires source-code edits and git commit)
73
+
74
+ MUST finish:
75
+ - [ ] Original repro passes.
76
+ - [ ] Regression passes or missing seam documented.
77
+ - [ ] `[DEBUG-...]` logs removed from source.
78
+ - [ ] Throwaway harnesses deleted/moved.
79
+ - [ ] Winning hypothesis stated in commit/PR.
80
+ - [ ] Seam/locality blocker → recommend `/improve-codebase-architecture`.
81
+
82
+ Implementer returns results back to architect profile for Phase 7.
83
+
84
+ ## Context economy
85
+
86
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
87
+
88
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
89
+
90
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
91
+
92
+ Do not re-read unchanged files; use prior findings unless the file changed.
93
+
94
+ For logs or large outputs, search for the failing marker/error first using `Grep`. Read only surrounding ranges needed to prove or disprove a hypothesis.
95
+
96
+ ## 7. Save
97
+
98
+ **OWNER: Architect profile** (writes to `.scratch/`)
99
+
100
+ Write the full diagnosis (hypotheses, instrumentation, root cause, fix) to `.scratch/diagnoses/<date>/diagnose-<slug>.md`.
101
+
102
+ Return completion with: diagnosis file path, root cause summary, fix applied, status, and recommended next command (typically `/verify` then `/review` then `/commit-and-document`).
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: explore
3
+ description: Map the codebase or a specific area to understand structure, dependencies, and key components. Use before planning features or refactors, or when entering an unfamiliar area.
4
+ ---
5
+
6
+ # Explore
7
+
8
+ Purpose: build a mental map of an area before making changes.
9
+
10
+ ## 1. Identify target
11
+
12
+ Determine what to explore:
13
+
14
+ - User-provided area, module, or feature
15
+ - Entire codebase if no specific target
16
+ - Recently changed areas if user says "what changed"
17
+
18
+ If the target is unclear, ask one short question via `AskUserQuestion` and stop.
19
+
20
+ ## 2. Read structure
21
+
22
+ Start with:
23
+
24
+ - `Glob` to find file structure
25
+ - `Grep` to find key patterns (imports, exports, entry points)
26
+ - Targeted `Read` on entry points and key files
27
+
28
+ Build understanding of:
29
+
30
+ - Module boundaries
31
+ - Key abstractions
32
+ - Data flow
33
+ - Dependencies
34
+
35
+ ## 3. Identify seams
36
+
37
+ Look for:
38
+
39
+ - Public interfaces (exported functions, classes, types)
40
+ - Integration points (API calls, database queries, file I/O)
41
+ - Test locations and coverage
42
+ - Configuration and environment dependencies
43
+
44
+ ## 4. Report findings
45
+
46
+ Return completion with:
47
+
48
+ - modules/components identified
49
+ - key dependencies and relationships
50
+ - seams and integration points
51
+ - recommended next command (typically `/fix`, `/feature`, or `/refactor` if changes needed, `/tdd` if implementation needed)
52
+
53
+ ## Context economy
54
+
55
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
56
+
57
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
58
+
59
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
60
+
61
+ Do not re-read unchanged files; use prior findings unless the file changed.
@@ -0,0 +1,66 @@
1
+ ---
2
+ name: feature
3
+ description: Multi-phase workflow for implementing new features. Explore codebase, design solution, propose plan, approve, and implement. Use for new features, major enhancements, or functionality that requires architectural decisions.
4
+ ---
5
+
6
+ # Feature
7
+
8
+ RULE: Understand the codebase and design before implementing. Features often require architectural decisions.
9
+
10
+ ## 1. Explore (Architect profile)
11
+
12
+ **OWNER: Architect profile** (read-only analysis)
13
+
14
+ 1. Use `explore` skill to map the relevant area.
15
+ 2. Understand existing patterns, seams, and dependencies.
16
+ 3. Identify where the feature fits.
17
+
18
+ ## 2. Design (Architect profile)
19
+
20
+ **OWNER: Architect profile** (read-only design)
21
+
22
+ 1. Propose design with rationale.
23
+ 2. Document design in `.scratch/features/<date>/design.md`.
24
+ 3. Include architectural decisions and trade-offs.
25
+ 4. Present design to user.
26
+ 5. Wait for user approval via `AskUserQuestion`.
27
+
28
+ ## 3. Plan implementation (Architect profile)
29
+
30
+ **OWNER: Architect profile** (read-only planning)
31
+
32
+ 1. Break feature into implementable steps.
33
+ 2. Each step should be independently testable.
34
+ 3. Document plan in `.scratch/features/<date>/plan.md`.
35
+ 4. Present plan to user.
36
+ 5. Wait for user approval via `AskUserQuestion`.
37
+
38
+ ## 4. Implement (Implementer profile)
39
+
40
+ **OWNER: Implementer profile** (requires source-code edits)
41
+
42
+ Delegate to implementer profile via `Agent` tool. Implementer executes:
43
+
44
+ 1. For each step in the plan:
45
+ - Write tests first if using TDD approach.
46
+ - Implement the change using `Edit` or `Write`.
47
+ - Run tests via `Bash` to verify.
48
+ - Commit if tests pass.
49
+ 2. If tests fail, stop and report.
50
+
51
+ ## 5. Verify and report
52
+
53
+ Implementer returns completion with:
54
+ - feature implemented
55
+ - tests status (all passing)
56
+ - recommended next command (typically `/verify` then `/review` then `/commit-and-document`)
57
+
58
+ ## Context economy
59
+
60
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
61
+
62
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
63
+
64
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
65
+
66
+ Do not re-read unchanged files; use prior findings unless the file changed.
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: fix
3
+ description: Multi-phase workflow for bug diagnosis and repair. Diagnose root cause, propose fix, approve, and implement. Use for bugs, regressions, or unexpected behavior.
4
+ ---
5
+
6
+ # Fix
7
+
8
+ RULE: Understand the bug before proposing a fix. Never guess at root cause.
9
+
10
+ ## 1. Diagnose (Architect profile)
11
+
12
+ **OWNER: Architect profile** (read-only analysis)
13
+
14
+ 1. Use `diagnose` skill to investigate the bug.
15
+ 2. Follow the diagnose skill's phases: feedback loop, reproduce, hypothesize, instrument.
16
+ 3. Identify root cause and propose fix.
17
+ 4. Present findings to user.
18
+ 5. Wait for user approval via `AskUserQuestion`.
19
+
20
+ ## 2. Plan fix (Architect profile)
21
+
22
+ **OWNER: Architect profile** (read-only planning)
23
+
24
+ 1. Document the fix plan in `.scratch/fixes/<date>/plan.md`.
25
+ 2. Include root cause, proposed solution, and test strategy.
26
+ 3. Present plan to user.
27
+ 4. Wait for user approval via `AskUserQuestion`.
28
+
29
+ ## 3. Implement fix (Implementer profile)
30
+
31
+ **OWNER: Implementer profile** (requires source-code edits)
32
+
33
+ Delegate to implementer profile via `Agent` tool. Implementer executes:
34
+
35
+ 1. Write regression test first using `Write` or `Edit`.
36
+ 2. Run test via `Bash` to verify it fails (red phase).
37
+ 3. Implement fix using `Edit` or `Write`.
38
+ 4. Run test via `Bash` to verify it passes (green phase).
39
+ 5. Run full test suite via `Bash`.
40
+ 6. If all tests pass, commit.
41
+
42
+ ## 4. Verify and report
43
+
44
+ Implementer returns completion with:
45
+ - root cause identified
46
+ - fix implemented
47
+ - regression test added
48
+ - all tests passing
49
+ - recommended next command (typically `/verify` then `/review` then `/commit-and-document`)
50
+
51
+ ## Context economy
52
+
53
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
54
+
55
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
56
+
57
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
58
+
59
+ Do not re-read unchanged files; use prior findings unless the file changed.
@@ -0,0 +1,35 @@
1
+ ---
2
+ name: grill-with-docs
3
+ description: Deep-dive exploration of a specific area with documentation. Use when you need to thoroughly understand a complex component, algorithm, or subsystem.
4
+ ---
5
+
6
+ # Grill with Docs
7
+
8
+ RULE: Produce comprehensive documentation, not just code exploration.
9
+
10
+ ## Procedure
11
+
12
+ 1. Identify the target area for deep exploration.
13
+ 2. Use `Glob` and `Grep` to locate all relevant files.
14
+ 3. Use `Read` to understand each component in detail.
15
+ 4. Trace data flow, control flow, and dependencies.
16
+ 5. Document findings in `.scratch/grills/<date>/<topic>.md` using `Write`.
17
+ 6. Include diagrams (text-based), code examples, and explanations.
18
+ 7. Identify key insights, potential issues, and recommendations.
19
+
20
+ ## Context economy
21
+
22
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
23
+
24
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
25
+
26
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
27
+
28
+ Do not re-read unchanged files; use prior findings unless the file changed.
29
+
30
+ ## Complete
31
+
32
+ Return completion with:
33
+ - documentation location
34
+ - key findings and insights
35
+ - recommended next command (typically `/feature` or `/refactor` if changes needed)
@@ -0,0 +1,39 @@
1
+ ---
2
+ name: improve-codebase-architecture
3
+ description: Analyze and improve codebase architecture. Use for structural improvements, better organization, or architectural refactoring.
4
+ ---
5
+
6
+ # Improve Codebase Architecture
7
+
8
+ RULE: Architecture changes should improve maintainability, testability, or clarity without changing behavior.
9
+
10
+ ## Procedure
11
+
12
+ 1. Explore current architecture using `explore` skill.
13
+ 2. Identify architectural issues:
14
+ - Poor separation of concerns
15
+ - Tight coupling
16
+ - Code duplication
17
+ - Unclear boundaries
18
+ - Inconsistent patterns
19
+ 3. Propose architectural improvements with rationale.
20
+ 4. Document improvements in `.scratch/architecture/<date>/proposal.md` using `Write`.
21
+ 5. Review with user via `AskUserQuestion`.
22
+ 6. If approved, create implementation plan and delegate to implementer profile.
23
+
24
+ ## Context economy
25
+
26
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
27
+
28
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
29
+
30
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
31
+
32
+ Do not re-read unchanged files; use prior findings unless the file changed.
33
+
34
+ ## Complete
35
+
36
+ Return completion with:
37
+ - architecture proposal location
38
+ - key improvements identified
39
+ - recommended next command (typically `/refactor` to implement changes)
@@ -0,0 +1,34 @@
1
+ ---
2
+ name: prototype
3
+ description: Create a quick prototype or proof-of-concept. Use for exploratory coding, trying out ideas, or validating approaches before committing to a design.
4
+ ---
5
+
6
+ # Prototype
7
+
8
+ RULE: Prototypes are throwaway code. Mark them clearly. Don't polish or test them.
9
+
10
+ ## Procedure
11
+
12
+ 1. Clarify what to prototype and the goal.
13
+ 2. Create prototype in isolated location (e.g., `.scratch/prototypes/<name>/`).
14
+ 3. Write minimal code to demonstrate the idea.
15
+ 4. Use `Write` to create files.
16
+ 5. Run prototype via `Bash` to demonstrate behavior.
17
+ 6. Document findings and recommendations.
18
+
19
+ ## Context economy
20
+
21
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
22
+
23
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
24
+
25
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
26
+
27
+ Do not re-read unchanged files; use prior findings unless the file changed.
28
+
29
+ ## Complete
30
+
31
+ Return completion with:
32
+ - prototype location
33
+ - findings and insights
34
+ - recommendations for next steps (proceed with design, explore alternative, or abandon)
@@ -0,0 +1,59 @@
1
+ ---
2
+ name: refactor
3
+ description: Multi-phase workflow for improving code structure. Diagnose structural issues, propose solutions, approve, and implement. Use for code smells, architectural improvements, or structural changes that don't change behavior.
4
+ ---
5
+
6
+ # Refactor
7
+
8
+ RULE: Refactoring changes structure, not behavior. All tests must pass before and after.
9
+
10
+ ## 1. Diagnose structural issues (Architect profile)
11
+
12
+ **OWNER: Architect profile** (read-only analysis)
13
+
14
+ 1. Read relevant code via `Glob`, `Grep`, and targeted `Read`.
15
+ 2. Identify code smells, architectural issues, or improvement opportunities.
16
+ 3. Propose refactoring plan with rationale.
17
+ 4. Present findings to user.
18
+ 5. Wait for user approval via `AskUserQuestion`.
19
+
20
+ ## 2. Plan refactoring (Architect profile)
21
+
22
+ **OWNER: Architect profile** (read-only planning)
23
+
24
+ 1. Break refactoring into safe, incremental steps.
25
+ 2. Each step should preserve behavior and pass tests.
26
+ 3. Document the plan in `.scratch/refactors/<date>/plan.md`.
27
+ 4. Present plan to user.
28
+ 5. Wait for user approval via `AskUserQuestion`.
29
+
30
+ ## 3. Implement refactoring (Implementer profile)
31
+
32
+ **OWNER: Implementer profile** (requires source-code edits)
33
+
34
+ Delegate to implementer profile via `Agent` tool. Implementer executes:
35
+
36
+ 1. For each step in the plan:
37
+ - Make the change using `Edit` or `Write`.
38
+ - Run tests via `Bash` to verify behavior preserved.
39
+ - Commit if tests pass.
40
+ 2. If tests fail, stop and report.
41
+ 3. Do not proceed to next step until current step verified.
42
+
43
+ ## 4. Verify and report
44
+
45
+ Implementer returns completion with:
46
+ - what was refactored
47
+ - structural improvements achieved
48
+ - tests status (all passing)
49
+ - recommended next command (typically `/verify` then `/review` then `/commit-and-document`)
50
+
51
+ ## Context economy
52
+
53
+ Before broad reads, locate relevant files/symbols with `Glob`, `Grep`, or targeted file reads.
54
+
55
+ Prefer targeted `Read` with line ranges or block reads once the relevant area is known.
56
+
57
+ Read full files only when structure, ordering, or surrounding context is required for correctness.
58
+
59
+ Do not re-read unchanged files; use prior findings unless the file changed.