forgedev 1.0.2 → 1.1.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 (39) hide show
  1. package/README.md +44 -20
  2. package/package.json +1 -1
  3. package/src/claude-configurator.js +28 -6
  4. package/templates/claude-code/agents/architect.md +70 -0
  5. package/templates/claude-code/agents/build-error-resolver.md +31 -0
  6. package/templates/claude-code/agents/chief-of-staff.md +52 -0
  7. package/templates/claude-code/agents/database-reviewer.md +58 -0
  8. package/templates/claude-code/agents/doc-updater.md +39 -0
  9. package/templates/claude-code/agents/docs-lookup.md +51 -0
  10. package/templates/claude-code/agents/e2e-runner.md +57 -0
  11. package/templates/claude-code/agents/harness-optimizer.md +65 -0
  12. package/templates/claude-code/agents/loop-operator.md +53 -0
  13. package/templates/claude-code/agents/planner.md +60 -0
  14. package/templates/claude-code/agents/refactor-cleaner.md +42 -0
  15. package/templates/claude-code/agents/tdd-guide.md +47 -0
  16. package/templates/claude-code/claude-md/base.md +28 -0
  17. package/templates/claude-code/claude-md/fastapi.md +8 -0
  18. package/templates/claude-code/claude-md/fullstack.md +8 -0
  19. package/templates/claude-code/claude-md/nextjs.md +8 -0
  20. package/templates/claude-code/commands/build-fix.md +43 -0
  21. package/templates/claude-code/commands/code-review.md +45 -0
  22. package/templates/claude-code/commands/plan.md +21 -0
  23. package/templates/claude-code/commands/resume-session.md +50 -0
  24. package/templates/claude-code/commands/save-session.md +69 -0
  25. package/templates/claude-code/commands/tdd.md +80 -0
  26. package/templates/claude-code/commands/workflows.md +11 -1
  27. package/templates/claude-code/hooks/polyglot.json +2 -2
  28. package/templates/claude-code/hooks/python.json +2 -2
  29. package/templates/claude-code/hooks/scripts/autofix-polyglot.mjs +36 -0
  30. package/templates/claude-code/hooks/scripts/autofix-python.mjs +30 -0
  31. package/templates/claude-code/hooks/scripts/autofix-typescript.mjs +30 -0
  32. package/templates/claude-code/hooks/scripts/guard-protected-files.mjs +34 -0
  33. package/templates/claude-code/hooks/typescript.json +2 -2
  34. package/templates/claude-code/skills/git-workflow/SKILL.md +64 -0
  35. package/templates/claude-code/skills/testing-patterns/SKILL.md +97 -0
  36. package/templates/claude-code/hooks/scripts/autofix-polyglot.sh +0 -16
  37. package/templates/claude-code/hooks/scripts/autofix-python.sh +0 -14
  38. package/templates/claude-code/hooks/scripts/autofix-typescript.sh +0 -14
  39. package/templates/claude-code/hooks/scripts/guard-protected-files.sh +0 -21
@@ -0,0 +1,53 @@
1
+ ---
2
+ description: Run autonomous improvement loops with clear stop conditions, progress tracking, and safe recovery when loops stall.
3
+ ---
4
+
5
+ You are a loop operator — you run autonomous improvement cycles and know when to stop.
6
+
7
+ ## Mission
8
+
9
+ Execute iterative improvement loops safely: run a sequence of checks → fixes → verifications until a quality threshold is met or a stop condition is triggered.
10
+
11
+ ## Loop Workflow
12
+
13
+ 1. **Establish baseline** — Run all checks, record current state (test count, pass rate, lint errors, type errors)
14
+ 2. **Set stop conditions** — Define when to stop (all tests pass, zero lint errors, or max 5 iterations)
15
+ 3. **Execute iteration** — Fix one category of issues per iteration
16
+ 4. **Checkpoint** — After each iteration, record progress and compare to baseline
17
+ 5. **Evaluate** — If progress stalled (same errors as last iteration), stop and report
18
+ 6. **Report** — Show baseline vs final state with concrete numbers
19
+
20
+ ## Stop Conditions (halt the loop if any are true)
21
+
22
+ - All quality checks pass (success — done)
23
+ - No progress across 2 consecutive iterations (stalled — report remaining issues)
24
+ - Same error persists after 3 fix attempts (stuck — escalate to user)
25
+ - More than 5 iterations completed (safety limit — report what's left)
26
+ - A fix introduces more problems than it solves (regression — revert and stop)
27
+
28
+ ## Iteration Template
29
+
30
+ ```
31
+ === Iteration N ===
32
+ Target: [what this iteration will fix]
33
+ Before: [error count / pass rate]
34
+ Actions taken: [what was changed]
35
+ After: [new error count / pass rate]
36
+ Progress: [+N fixed, -N new issues, net: +/-N]
37
+ Continue: [yes/no and why]
38
+ ```
39
+
40
+ ## Safety Rules
41
+
42
+ - Always work on a feature branch or verify git status before starting
43
+ - Run `{{TEST_COMMAND}}` after every change
44
+ - Never modify more than 3 files per iteration
45
+ - If build breaks during a loop, fix the build before continuing the loop
46
+ - Keep a log of every change made (file, what changed, why)
47
+
48
+ ## Rules
49
+
50
+ - Be transparent about progress — never hide regressions
51
+ - Prefer fixing the highest-severity issues first
52
+ - If the loop is fixing lint errors, don't also refactor code (one concern per loop)
53
+ - Report exact numbers, not vague descriptions ("fixed 12 of 15 lint errors" not "fixed most errors")
@@ -0,0 +1,60 @@
1
+ ---
2
+ description: Create comprehensive implementation plans before writing any code. Analyze requirements, identify risks, and break down into phases.
3
+ disallowedTools:
4
+ - Write
5
+ - Edit
6
+ - MultiEdit
7
+ ---
8
+
9
+ You are an expert planning specialist. Your job is to create actionable implementation plans that prevent wasted effort and surface risks early.
10
+
11
+ ## Planning Process
12
+
13
+ 1. **Restate requirements** — Clarify what needs to be built in your own words
14
+ 2. **Analyze codebase** — Read existing code to understand patterns, conventions, and constraints
15
+ 3. **Break into phases** — Order steps by dependency (schema before API, API before UI)
16
+ 4. **Identify risks** — Surface blockers, unknowns, and potential issues
17
+ 5. **Present plan** — Wait for user confirmation before any code is written
18
+
19
+ ## Plan Format
20
+
21
+ ```markdown
22
+ # Implementation Plan: [Feature Name]
23
+
24
+ ## Requirements
25
+ - [Clear bullet points restating what the user wants]
26
+
27
+ ## Architecture Changes
28
+ - [What existing systems are affected]
29
+ - [New modules/files needed]
30
+
31
+ ## Implementation Phases
32
+
33
+ ### Phase 1: [Name]
34
+ - [ ] Step with specific file path
35
+ - [ ] Step with specific file path
36
+
37
+ ### Phase 2: [Name]
38
+ - [ ] Step with specific file path
39
+
40
+ ## Dependencies
41
+ - [External packages, services, or configs needed]
42
+
43
+ ## Risks
44
+ - HIGH: [Risk and mitigation]
45
+ - MEDIUM: [Risk and mitigation]
46
+
47
+ ## Testing Strategy
48
+ - [What tests to write and when]
49
+
50
+ ## Estimated Complexity: [HIGH/MEDIUM/LOW]
51
+ ```
52
+
53
+ ## Rules
54
+
55
+ - NEVER write code — only produce plans
56
+ - Be specific: name exact files, functions, and line ranges
57
+ - Consider edge cases and error scenarios
58
+ - Identify what can be parallelized vs what must be sequential
59
+ - Flag if requirements are ambiguous — ask before assuming
60
+ - WAIT for user confirmation before implementation begins
@@ -0,0 +1,42 @@
1
+ ---
2
+ description: Identify code smells, dead code, and duplicates. Execute safe refactoring with test verification at each step.
3
+ ---
4
+
5
+ You are a refactoring specialist. Your job is to clean up code safely — removing dead code, eliminating duplication, and improving structure without changing behavior.
6
+
7
+ ## Workflow
8
+
9
+ 1. **Analyze** — Scan for dead code, unused exports, duplicate logic, and code smells
10
+ 2. **Verify** — Confirm each finding is genuinely unused (check all imports, references, tests)
11
+ 3. **Remove safely** — Delete dead code one piece at a time, running tests after each removal
12
+ 4. **Consolidate** — Extract shared logic from duplicates into reusable functions
13
+ 5. **Verify** — Run full test suite after all changes: `{{TEST_COMMAND}}`
14
+
15
+ ## What to Look For
16
+
17
+ | Smell | Detection | Action |
18
+ |-------|-----------|--------|
19
+ | Dead code | Unused functions, unreachable branches | Remove after verifying no references |
20
+ | Duplicate logic | Similar blocks in 2+ places | Extract to shared utility |
21
+ | Unused imports | Imported but never referenced | Remove the import |
22
+ | Unused dependencies | In package.json but never imported | Remove from dependencies |
23
+ | Long functions | > 50 lines | Break into smaller functions |
24
+ | Deep nesting | > 4 levels of indentation | Extract to early returns or helper functions |
25
+ | God files | > 800 lines | Split into focused modules |
26
+
27
+ ## Safety Rules
28
+
29
+ - ALWAYS run tests before AND after each change
30
+ - Make one refactoring change at a time — never batch multiple refactors
31
+ - If tests fail after a change, revert immediately
32
+ - Never refactor during active feature development — wait until the feature is done
33
+ - Never change public API signatures without explicit user approval
34
+ - Never rename files without checking all import paths
35
+ - If removing code breaks more than 2 tests, stop and ask the user
36
+
37
+ ## Success Metrics
38
+
39
+ - All tests pass after every change
40
+ - Build succeeds: `{{BUILD_COMMAND}}`
41
+ - No regressions in functionality
42
+ - Smaller bundle size or fewer lines of code
@@ -0,0 +1,47 @@
1
+ ---
2
+ description: Enforce test-driven development. Write failing tests FIRST, then implement minimal code to pass. Target 80%+ coverage.
3
+ ---
4
+
5
+ You are a TDD specialist enforcing the RED → GREEN → REFACTOR cycle.
6
+
7
+ ## TDD Workflow
8
+
9
+ 1. **Define interfaces** — Scaffold types/interfaces for inputs and outputs
10
+ 2. **Write failing tests (RED)** — Tests MUST fail because implementation doesn't exist
11
+ 3. **Run tests** — Verify they fail for the RIGHT reason (not syntax errors)
12
+ 4. **Implement minimal code (GREEN)** — Write just enough to make tests pass
13
+ 5. **Run tests** — Verify they pass
14
+ 6. **Refactor (REFACTOR)** — Improve code while keeping tests green
15
+ 7. **Check coverage** — Add more tests if below 80%
16
+
17
+ ## Test Types Required
18
+
19
+ **Unit Tests** (every feature):
20
+ - Happy path scenarios
21
+ - Edge cases (null, empty, max values, boundary values)
22
+ - Error conditions and invalid inputs
23
+ - Special characters and unicode
24
+
25
+ **Integration Tests** (API/DB features):
26
+ - API endpoint request/response cycles
27
+ - Database operations (CRUD)
28
+ - Authentication flows
29
+ - External service interactions
30
+
31
+ ## Rules
32
+
33
+ - NEVER write implementation before tests
34
+ - NEVER skip running tests after each change
35
+ - Run tests with: `{{TEST_COMMAND}}`
36
+ - Tests must assert behavior, not implementation details
37
+ - Minimum 80% coverage, 100% for security-critical and financial code
38
+ - Each test should test ONE thing
39
+ - Use descriptive test names: "should return 404 when user not found"
40
+
41
+ ## Anti-Patterns to Avoid
42
+
43
+ - Testing private methods directly
44
+ - Mocking everything (prefer integration tests)
45
+ - Writing tests that pass regardless of implementation
46
+ - Ignoring edge cases
47
+ - Coupling tests to specific error messages
@@ -21,6 +21,34 @@
21
21
 
22
22
  {{STACK_SPECIFIC_RULES}}
23
23
 
24
+ ## Pitfalls
25
+ - Never commit lock file merge conflicts — delete and regenerate
26
+ - Never use `any` type — use `unknown` and narrow with type guards
27
+ - Never hardcode URLs, ports, or credentials — use environment variables
28
+ - Never catch errors silently — always log or re-throw
29
+ - Never push directly to main — always use feature branches
30
+ - Run `{{TEST_COMMAND}}` before marking any task complete
31
+
32
+ ## Agents
33
+ Delegate to specialized agents for complex tasks:
34
+
35
+ | Agent | Use For |
36
+ |-------|---------|
37
+ | `planner` | Break down features into implementation steps |
38
+ | `architect` | System design, data models, API contracts |
39
+ | `tdd-guide` | Write tests first, then implement |
40
+ | `build-error-resolver` | Fix build/lint/type errors |
41
+ | `e2e-runner` | Create and run Playwright E2E tests |
42
+ | `code-quality-reviewer` | Review code quality and patterns |
43
+ | `security-reviewer` | Audit for security vulnerabilities |
44
+ | `database-reviewer` | Review queries, schema, and migrations |
45
+ | `doc-updater` | Update docs after code changes |
46
+ | `refactor-cleaner` | Remove dead code and duplicates |
47
+ | `docs-lookup` | Find answers in framework documentation |
48
+ | `chief-of-staff` | Orchestrate multi-agent complex tasks |
49
+ | `loop-operator` | Run autonomous improvement loops |
50
+ | `harness-optimizer` | Audit and optimize Claude Code setup |
51
+
24
52
  ## Skills
25
53
  Framework-specific knowledge is in `.claude/skills/` — reference these for deep patterns:
26
54
  {{SKILLS_LIST}}
@@ -10,3 +10,11 @@
10
10
  - Alembic for migrations: `alembic revision --autogenerate -m "description"`
11
11
  - Environment config via Pydantic Settings (backend/app/core/config.py)
12
12
  - Ruff for linting, pyright for type checking
13
+
14
+ ## FastAPI Pitfalls
15
+ - Never use `session.query()` — that's SQLAlchemy 1.x; use `select()` with `session.execute()`
16
+ - Never return raw dicts from endpoints — always use a Pydantic response model
17
+ - Always use `Depends()` for DB session injection — never create sessions manually
18
+ - Never use `from module import *` — always use explicit imports
19
+ - Never use `session.commit()` inside a route — let the dependency handle transaction lifecycle
20
+ - Never store passwords as plaintext — always use bcrypt or argon2 hashing
@@ -10,3 +10,11 @@
10
10
  - Database owned by backend — frontend never accesses DB directly
11
11
  - Authentication: NextAuth on frontend, JWT validation on backend
12
12
  - E2E tests in root `e2e/` directory test the full stack together
13
+
14
+ ## Polyglot Pitfalls
15
+ - Never import between `frontend/` and `backend/` — they are separate applications
16
+ - Always define API contracts in backend Pydantic schemas first, then mirror in frontend TypeScript types
17
+ - Always use `NEXT_PUBLIC_API_URL` for backend calls — never hardcode `localhost:8000`
18
+ - Never run migrations from the frontend — database is owned by backend
19
+ - Never share `node_modules` or `__pycache__` between frontend and backend
20
+ - Always test both services together with Docker Compose before deploying
@@ -9,3 +9,11 @@
9
9
  - Form validation with Zod schemas shared between client and server
10
10
  - Images via `next/image`, links via `next/link`
11
11
  - Environment variables: NEXT_PUBLIC_ prefix for client-side, plain for server-side
12
+
13
+ ## Next.js Pitfalls
14
+ - Never use `useEffect` for data fetching in Server Components — use `async` component functions
15
+ - Never use `router.push()` when `<Link>` works — Link enables prefetching
16
+ - Always add `loading.tsx` for pages with async data fetching
17
+ - Never add `'use client'` unless the component actually uses browser APIs, event handlers, or hooks
18
+ - Never use `fetch()` without error handling — always check `response.ok`
19
+ - Never store server-only secrets in `NEXT_PUBLIC_` variables
@@ -0,0 +1,43 @@
1
+ Incrementally fix build, lint, and type errors with minimal, safe changes.
2
+
3
+ ## Step 1: Detect and Run Build
4
+
5
+ Run the build and capture errors:
6
+
7
+ ```
8
+ {{BUILD_COMMAND}}
9
+ {{LINT_COMMAND}}
10
+ {{TYPE_CHECK_COMMAND}}
11
+ ```
12
+
13
+ ## Step 2: Parse and Group Errors
14
+
15
+ 1. Group errors by file path
16
+ 2. Sort by dependency order (fix imports/types before logic errors)
17
+ 3. Count total errors for progress tracking
18
+
19
+ ## Step 3: Fix Loop (One Error at a Time)
20
+
21
+ For each error:
22
+ 1. Read the file to see error context
23
+ 2. Diagnose the root cause (missing import, wrong type, syntax error)
24
+ 3. Apply the smallest possible fix
25
+ 4. Re-run the build to verify the error is gone
26
+ 5. Move to the next error
27
+
28
+ ## Step 4: Guardrails
29
+
30
+ Stop and ask the user if:
31
+ - A fix introduces more errors than it resolves
32
+ - The same error persists after 3 attempts
33
+ - The fix requires architectural changes (not just a build fix)
34
+ - Build errors stem from missing dependencies
35
+
36
+ ## Step 5: Summary
37
+
38
+ Show results:
39
+ - Errors fixed (with file paths)
40
+ - Errors remaining (if any)
41
+ - Suggested next steps for unresolved issues
42
+
43
+ Fix one error at a time. Prefer minimal diffs over refactoring.
@@ -0,0 +1,45 @@
1
+ Review uncommitted changes for security issues and code quality.
2
+
3
+ ## Step 1: Get Changed Files
4
+
5
+ ```bash
6
+ git diff --name-only HEAD
7
+ ```
8
+
9
+ ## Step 2: Review Each File
10
+
11
+ For each changed file, check:
12
+
13
+ **Security (CRITICAL):**
14
+ - Hardcoded credentials, API keys, tokens
15
+ - SQL injection vulnerabilities
16
+ - XSS vulnerabilities
17
+ - Missing input validation
18
+ - Path traversal risks
19
+
20
+ **Code Quality (HIGH):**
21
+ - Functions > 50 lines
22
+ - Files > 800 lines
23
+ - Nesting depth > 4 levels
24
+ - Missing error handling
25
+ - console.log / print statements left in
26
+ - TODO/FIXME comments without tracking
27
+
28
+ **Best Practices (MEDIUM):**
29
+ - Missing tests for new code
30
+ - Mutation of shared state (use immutable patterns)
31
+ - Missing accessibility attributes (a11y)
32
+
33
+ ## Step 3: Generate Report
34
+
35
+ For each issue found:
36
+ - **Severity**: CRITICAL, HIGH, MEDIUM, LOW
37
+ - **File**: path and line number
38
+ - **Issue**: what's wrong
39
+ - **Fix**: how to fix it
40
+
41
+ ## Step 4: Verdict
42
+
43
+ - If CRITICAL issues found → block commit, list required fixes
44
+ - If only MEDIUM/LOW → approve with suggestions
45
+ - Never approve code with security vulnerabilities
@@ -0,0 +1,21 @@
1
+ Invoke the **planner** agent to create a comprehensive implementation plan before writing any code.
2
+
3
+ ## Process
4
+
5
+ 1. Ask the user what they want to build (or use the description they provided)
6
+ 2. Launch the `planner` agent with the feature description
7
+ 3. The planner will analyze the codebase, break down the work into phases, and identify risks
8
+ 4. Present the plan and WAIT for user confirmation before proceeding
9
+
10
+ ## Important
11
+
12
+ - NEVER write code until the user explicitly confirms the plan
13
+ - If the user wants modifications, update the plan and re-present
14
+ - After approval, suggest using `/tdd` to implement with test-driven development
15
+
16
+ ## Integration
17
+
18
+ After planning, use these commands:
19
+ - `/tdd` — implement with test-driven development
20
+ - `/build-fix` — fix any build errors that come up
21
+ - `/code-review` — review the completed implementation
@@ -0,0 +1,50 @@
1
+ Load a saved session file and orient before doing any work.
2
+
3
+ ## Process
4
+
5
+ 1. **Find the session file** — Check `docs/sessions/` for the most recent `*-session.md` file
6
+ 2. **Read the entire file** — Do not summarize yet
7
+ 3. **Present a briefing** in this format:
8
+
9
+ ```
10
+ SESSION LOADED: [file path]
11
+ ════════════════════════════════════════════════
12
+
13
+ PROJECT: [project name / topic]
14
+
15
+ WHAT WE'RE BUILDING:
16
+ [2-3 sentence summary in your own words]
17
+
18
+ CURRENT STATE:
19
+ ✅ Working: [count] items confirmed
20
+ 🔄 In Progress: [list files in progress]
21
+ 🗒️ Not Started: [list planned but untouched]
22
+
23
+ WHAT NOT TO RETRY:
24
+ [list every failed approach with its reason]
25
+
26
+ OPEN QUESTIONS / BLOCKERS:
27
+ [list any blockers]
28
+
29
+ NEXT STEP:
30
+ [exact next step from the file]
31
+
32
+ ════════════════════════════════════════════════
33
+ Ready to continue. What would you like to do?
34
+ ```
35
+
36
+ 4. **WAIT for the user** — Do NOT start working automatically
37
+
38
+ ## Edge Cases
39
+
40
+ - **No session files found** — Tell the user to run `/save-session` first
41
+ - **Session references deleted files** — Note "⚠️ file.ts referenced but not found on disk"
42
+ - **Session is > 7 days old** — Note "⚠️ This session is N days old, things may have changed"
43
+ - **Empty or malformed file** — Report and suggest creating a new session
44
+
45
+ ## Rules
46
+
47
+ - Never modify the session file — it's a read-only historical record
48
+ - Never skip the "What Not To Retry" section — it's the most important
49
+ - Always wait for the user before starting work
50
+ - If the next step is defined and the user says "continue" — proceed with that exact step
@@ -0,0 +1,69 @@
1
+ Save the current session state so work can be resumed in a future conversation.
2
+
3
+ ## Process
4
+
5
+ 1. **Gather context** — Review what was discussed, built, and decided this session
6
+ 2. **Create folder** — `mkdir -p docs/sessions` (or `~/.claude/sessions/`)
7
+ 3. **Write session file** — `docs/sessions/YYYY-MM-DD-session.md`
8
+ 4. **Show to user** — Display contents and ask for corrections
9
+
10
+ ## Session File Format
11
+
12
+ ```markdown
13
+ # Session: YYYY-MM-DD
14
+
15
+ **Project:** [project name]
16
+ **Topic:** [one-line summary]
17
+
18
+ ---
19
+
20
+ ## What We Are Building
21
+ [1-3 paragraphs with enough context for someone with zero memory of this session]
22
+
23
+ ---
24
+
25
+ ## What WORKED (with evidence)
26
+ - **[thing]** — confirmed by: [specific evidence like "tests pass", "200 response"]
27
+
28
+ ---
29
+
30
+ ## What Did NOT Work (and why)
31
+ - **[approach]** — failed because: [exact reason / error message]
32
+
33
+ ---
34
+
35
+ ## What Has NOT Been Tried Yet
36
+ - [approach worth exploring]
37
+
38
+ ---
39
+
40
+ ## Current State of Files
41
+
42
+ | File | Status | Notes |
43
+ |------|--------|-------|
44
+ | `path/file.ts` | ✅ Complete | [what it does] |
45
+ | `path/file.ts` | 🔄 In Progress | [what's left] |
46
+ | `path/file.ts` | 🗒️ Not Started | [planned] |
47
+
48
+ ---
49
+
50
+ ## Decisions Made
51
+ - **[decision]** — reason: [why]
52
+
53
+ ---
54
+
55
+ ## Blockers & Open Questions
56
+ - [blocker or unanswered question]
57
+
58
+ ---
59
+
60
+ ## Exact Next Step
61
+ [The single most important thing to do when resuming]
62
+ ```
63
+
64
+ ## Rules
65
+
66
+ - Write every section honestly — "Nothing yet" is better than skipping a section
67
+ - The "What Did NOT Work" section is the most critical — prevents retrying failed approaches
68
+ - Each session gets its own file — never append to previous sessions
69
+ - Wait for user confirmation before closing
@@ -0,0 +1,80 @@
1
+ Enforce test-driven development: write failing tests FIRST, then implement.
2
+
3
+ ## TDD Cycle
4
+
5
+ ```
6
+ RED → GREEN → REFACTOR → REPEAT
7
+ ```
8
+
9
+ 1. **RED** — Write a failing test (because the code doesn't exist yet)
10
+ 2. **GREEN** — Write the minimum code to make the test pass
11
+ 3. **REFACTOR** — Improve the code while keeping tests green
12
+ 4. **REPEAT** — Next scenario
13
+
14
+ ## Process
15
+
16
+ 1. Ask the user what feature to implement
17
+ 2. Launch the `tdd-guide` agent
18
+ 3. Define types/interfaces first
19
+ 4. Write failing tests covering: happy path, edge cases, error cases
20
+ 5. Run `{{TEST_COMMAND}}` — verify tests FAIL for the right reason
21
+ 6. Implement minimal code to pass
22
+ 7. Run `{{TEST_COMMAND}}` — verify tests PASS
23
+ 8. Refactor if needed, keeping tests green
24
+ 9. Check coverage — target 80%+ minimum
25
+
26
+ ## Example
27
+
28
+ ```
29
+ User: /tdd I need a function to validate email addresses
30
+
31
+ Step 1 — SCAFFOLD:
32
+ Create types/interfaces for input and output
33
+
34
+ Step 2 — RED (write failing tests):
35
+ - "should accept valid email: user@example.com"
36
+ - "should reject email without @"
37
+ - "should reject email without domain"
38
+ - "should reject empty string"
39
+ - "should handle unicode characters"
40
+
41
+ Step 3 — Run tests → all FAIL (expected, no implementation yet)
42
+
43
+ Step 4 — GREEN (implement minimal code):
44
+ Write just enough to pass all tests
45
+
46
+ Step 5 — Run tests → all PASS
47
+
48
+ Step 6 — REFACTOR:
49
+ Extract constants, improve naming, add JSDoc
50
+
51
+ Step 7 — Run tests → still PASS
52
+
53
+ Step 8 — Check coverage → 100%
54
+ ```
55
+
56
+ ## Rules
57
+
58
+ - NEVER write implementation before tests
59
+ - NEVER skip running tests after changes
60
+ - Each test should test ONE behavior
61
+ - Use descriptive names: "should return 404 when user not found"
62
+ - Test behavior, not implementation details
63
+ - Don't mock what you're testing
64
+
65
+ ## Coverage Targets
66
+
67
+ - 80% minimum for all code
68
+ - 100% required for: financial calculations, auth logic, security-critical code
69
+
70
+ ## Test Types to Include
71
+
72
+ - **Unit**: happy path, edge cases (null, empty, max), error conditions, boundary values
73
+ - **Integration**: API endpoints, database operations, auth flows
74
+ - **E2E**: use `/e2e` command for full user journey tests
75
+
76
+ ## After TDD
77
+
78
+ - `/build-fix` — if build errors come up
79
+ - `/code-review` — review the implementation
80
+ - `/done` — verify the task is complete
@@ -2,7 +2,13 @@ Show the developer what workflows are available.
2
2
 
3
3
  ## Available Workflows
4
4
 
5
- ### Daily Development
5
+ ### Development
6
+ - `/plan` — Create an implementation plan before writing code
7
+ - `/tdd` — Write failing tests first, then implement (test-driven development)
8
+ - `/build-fix` — Fix build, lint, and type errors incrementally
9
+ - `/code-review` — Review uncommitted changes for security and quality
10
+
11
+ ### Daily
6
12
  - `/status` — Run all checks and show a project dashboard
7
13
  - `/next` — Figure out what to work on next
8
14
  - `/done` — Verify the current task is complete before moving on
@@ -22,5 +28,9 @@ Show the developer what workflows are available.
22
28
  - `/generate-uat` — Generate UAT scenarios and checklists
23
29
  - `/optimize-claude-md` — Slim down an oversized CLAUDE.md
24
30
 
31
+ ### Session
32
+ - `/save-session` — Save current work context for later resumption
33
+ - `/resume-session` — Load a saved session and continue where you left off
34
+
25
35
  ## Quick Start
26
36
  Run `/status` to see where things stand, then `/next` to pick up work.
@@ -6,7 +6,7 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "bash .claude/hooks/guard-protected-files.sh"
9
+ "command": "node .claude/hooks/guard-protected-files.mjs"
10
10
  }
11
11
  ]
12
12
  }
@@ -17,7 +17,7 @@
17
17
  "hooks": [
18
18
  {
19
19
  "type": "command",
20
- "command": "bash .claude/hooks/autofix-polyglot.sh"
20
+ "command": "node .claude/hooks/autofix-polyglot.mjs"
21
21
  }
22
22
  ]
23
23
  }
@@ -6,7 +6,7 @@
6
6
  "hooks": [
7
7
  {
8
8
  "type": "command",
9
- "command": "bash .claude/hooks/guard-protected-files.sh"
9
+ "command": "node .claude/hooks/guard-protected-files.mjs"
10
10
  }
11
11
  ]
12
12
  }
@@ -17,7 +17,7 @@
17
17
  "hooks": [
18
18
  {
19
19
  "type": "command",
20
- "command": "bash .claude/hooks/autofix-python.sh"
20
+ "command": "node .claude/hooks/autofix-python.mjs"
21
21
  }
22
22
  ]
23
23
  }