@claude-pw/framework 0.3.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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.es.md +173 -0
  3. package/README.ja.md +173 -0
  4. package/README.md +173 -0
  5. package/README.pt-br.md +173 -0
  6. package/README.zh-cn.md +173 -0
  7. package/RELEASES.md +66 -0
  8. package/install.js +593 -0
  9. package/package.json +35 -0
  10. package/templates/CHANGELOG.md +6 -0
  11. package/templates/CLAUDE.md.tpl +38 -0
  12. package/templates/Makefile +37 -0
  13. package/templates/PLAN.md.tpl +18 -0
  14. package/templates/STATUS.md.tpl +15 -0
  15. package/templates/claude/agents/codebase-mapper.md +105 -0
  16. package/templates/claude/agents/debugger.md +90 -0
  17. package/templates/claude/agents/decision-impact.md +36 -0
  18. package/templates/claude/agents/implementer.md +73 -0
  19. package/templates/claude/agents/interface-reviewer.md +22 -0
  20. package/templates/claude/agents/learning-extractor.md +104 -0
  21. package/templates/claude/agents/phase-validator.md +108 -0
  22. package/templates/claude/agents/plan-checker.md +18 -0
  23. package/templates/claude/agents/researcher.md +85 -0
  24. package/templates/claude/agents/session-recovery.md +127 -0
  25. package/templates/claude/agents/spike-explorer.md +34 -0
  26. package/templates/claude/commands/cpw-debug.md +116 -0
  27. package/templates/claude/commands/cpw-discuss.md +70 -0
  28. package/templates/claude/commands/cpw-health.md +67 -0
  29. package/templates/claude/commands/cpw-impact.md +22 -0
  30. package/templates/claude/commands/cpw-next-step.md +492 -0
  31. package/templates/claude/commands/cpw-pause.md +49 -0
  32. package/templates/claude/commands/cpw-quick.md +83 -0
  33. package/templates/claude/commands/cpw-reflect.md +209 -0
  34. package/templates/claude/commands/cpw-startup.md +321 -0
  35. package/templates/claude/commands/cpw-todos.md +100 -0
  36. package/templates/claude/hooks/cpw-context-monitor.js +59 -0
  37. package/templates/claude/hooks/cpw-statusline.js +36 -0
  38. package/templates/claude/rules/git.md +27 -0
  39. package/templates/claude/rules/interfaces.md +9 -0
  40. package/templates/claude/rules/testing.md +8 -0
  41. package/templates/claude/settings.json +42 -0
  42. package/templates/docs/architecture.md +4 -0
  43. package/templates/docs/codebase-map.md +3 -0
  44. package/templates/docs/conventions.md +3 -0
  45. package/templates/docs/interfaces.md +10 -0
  46. package/templates/docs/tech-debt.md +3 -0
  47. package/templates/docs/tooling.md +15 -0
  48. package/templates/gitignore +17 -0
  49. package/templates/husky/pre-commit +23 -0
  50. package/templates/planning/config.json +11 -0
  51. package/templates/planning/learnings/applied.md +3 -0
  52. package/templates/planning/learnings/queue.md +5 -0
  53. package/templates/planning/quick/log.md +4 -0
  54. package/templates/plans/decisions.md +9 -0
  55. package/templates/plans/phase-0.md +57 -0
  56. package/templates/plans/phase-1.md +49 -0
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env node
2
+ // Statusline for claude-pw — writes context metrics to bridge file
3
+ // Receives JSON on stdin from Claude Code statusline system
4
+
5
+ const fs = require('fs');
6
+ const os = require('os');
7
+ const path = require('path');
8
+
9
+ let input = '';
10
+ process.stdin.setEncoding('utf8');
11
+ process.stdin.on('data', (chunk) => { input += chunk; });
12
+ process.stdin.on('end', () => {
13
+ try {
14
+ const data = JSON.parse(input);
15
+ const sessionId = data.session_id || 'unknown';
16
+ const usedPct = Math.floor(data.context_window?.used_percentage || 0);
17
+ const remainingPct = Math.floor(data.context_window?.remaining_percentage || 100);
18
+ const model = data.model?.display_name || 'Claude';
19
+ const cost = data.cost?.total_cost_usd || 0;
20
+
21
+ // Write bridge file for context monitor hook
22
+ const bridge = path.join(os.tmpdir(), `cpw-ctx-${sessionId}.json`);
23
+ fs.writeFileSync(bridge, JSON.stringify({ used_pct: usedPct, remaining_pct: remainingPct, ts: Math.floor(Date.now() / 1000) }));
24
+
25
+ // Display statusline
26
+ if (usedPct >= 80) {
27
+ process.stdout.write(`\x1b[31m${model} │ ctx ${usedPct}% ⚠ CRITICAL\x1b[0m │ $${cost}\n`);
28
+ } else if (usedPct >= 65) {
29
+ process.stdout.write(`\x1b[33m${model} │ ctx ${usedPct}% ⚠ WARNING\x1b[0m │ $${cost}\n`);
30
+ } else {
31
+ process.stdout.write(`${model} │ ctx ${usedPct}% │ $${cost}\n`);
32
+ }
33
+ } catch (e) {
34
+ // Silent fail — never break the statusline
35
+ }
36
+ });
@@ -0,0 +1,27 @@
1
+ ---
2
+ globs: [".husky/**", ".git/hooks/**"]
3
+ ---
4
+ # Git
5
+ - Conventional Commits: type(scope): description
6
+ - Types: feat, fix, docs, chore, refactor, test, ci
7
+ - NEVER --no-verify
8
+ - ALWAYS make commit / make push
9
+ - One step = one atomic commit
10
+ - Read gitStrategy from .planning/config.json to determine branching behavior
11
+
12
+ ## Strategy: trunk-based (default)
13
+ - Commit and push directly to main/master
14
+ - No branches needed
15
+
16
+ ## Strategy: feature-branch
17
+ - At phase start: create branch `phase-N/[description]` from main
18
+ - Commit to branch during steps
19
+ - At phase end (after UAT): create PR to main, do NOT push directly to main
20
+ - After PR merged: pull main, start next phase branch from main
21
+
22
+ ## Strategy: gitflow
23
+ - Work from develop branch (create if it doesn't exist)
24
+ - At phase start: create branch `feature/phase-N-[description]` from develop
25
+ - Commit to branch during steps
26
+ - At phase end (after UAT): create PR to develop, do NOT push directly to develop
27
+ - Release branches created separately when ready to ship
@@ -0,0 +1,9 @@
1
+ ---
2
+ globs: ["src/interfaces/**"]
3
+ ---
4
+ # Interfaces
5
+ - Do NOT modify without RFC in plans/decisions.md
6
+ - Change -> update docs/interfaces.md + tests/contracts/
7
+ - Significant change -> /cpw-impact
8
+ - Strict types, no any/unknown without justification
9
+ - Each interface defines error types
@@ -0,0 +1,8 @@
1
+ ---
2
+ globs: ["tests/**", "**/*.test.*", "**/*.spec.*"]
3
+ ---
4
+ # Testing
5
+ - describe("[Module] - [Function]", ...)
6
+ - Contract: validate interface, not implementation
7
+ - Unit: no real I/O, use mocks
8
+ - New module -> contract tests first
@@ -0,0 +1,42 @@
1
+ {
2
+ "statusLine": {
3
+ "type": "command",
4
+ "command": "node .claude/hooks/cpw-statusline.js"
5
+ },
6
+ "hooks": {
7
+ "UserPromptSubmit": [
8
+ {
9
+ "matcher": "",
10
+ "hooks": [{
11
+ "type": "command",
12
+ "command": "prompt=\"$CLAUDE_USER_PROMPT\"; if [ ${#prompt} -gt 500 ] && ! echo \"$prompt\" | grep -qiE '(recuerda:|remember:)'; then exit 0; fi; if echo \"$prompt\" | grep -qiE '(\\?$|^(please |can you |could you |por favor |puedes |podrias |ayudame ))'; then exit 0; fi; if echo \"$prompt\" | grep -qiE '(^no[, ]|no uses|no hagas|don.t use|actually|en realidad|mejor usa|use .+ not|instead of|en vez de|nunca |always |siempre |recuerda:|remember:)'; then echo \"[CORRECTION DETECTED] Capture this correction in .planning/learnings/queue.md as a new entry with this exact format:\\n---\\n- **Date**: [today]\\n- **Correction**: [exact user correction text]\\n- **Context**: [what you were doing when corrected]\\n- **Command**: [active command from STATUS.md or the current slash command, e.g., cpw-next-step, cpw-debug, cpw-quick, or 'none' if no command is active]\\n- **Pattern**: [explicit if contains remember:/recuerda:, guardrail if contains nunca/always/siempre/never, correction for the rest]\\n- **Confidence**: [0.90 for explicit, 0.80 for guardrail, 0.70 for correction]\\n- **Validated**: no\\n---\"; fi"
13
+ }]
14
+ }
15
+ ],
16
+ "Stop": [
17
+ {
18
+ "matcher": "",
19
+ "hooks": [{
20
+ "type": "command",
21
+ "command": "queue='.planning/learnings/queue.md'; if [ -f \"$queue\" ] && grep -qE '^- \\*\\*Date\\*\\*:' \"$queue\" 2>/dev/null; then count=$(grep -c '^- \\*\\*Date\\*\\*:' \"$queue\" 2>/dev/null || echo 0); echo \"[AUTO-REFLECT] $count pending learning(s) in queue. Run /cpw-reflect to process them.\"; fi"
22
+ }]
23
+ }
24
+ ],
25
+ "PostToolUse": [
26
+ {
27
+ "matcher": "",
28
+ "hooks": [{
29
+ "type": "command",
30
+ "command": "node .claude/hooks/cpw-context-monitor.js"
31
+ }]
32
+ },
33
+ {
34
+ "matcher": "Write",
35
+ "hooks": [{
36
+ "type": "command",
37
+ "command": "echo 'Update STATUS.md if you changed stage'"
38
+ }]
39
+ }
40
+ ]
41
+ }
42
+ }
@@ -0,0 +1,4 @@
1
+ # Architecture
2
+
3
+ ## Stack
4
+ TODO: Phase 0, Step 0.1
@@ -0,0 +1,3 @@
1
+ # Codebase Map
2
+
3
+ TODO: Generated by /cpw-startup
@@ -0,0 +1,3 @@
1
+ # Conventions
2
+
3
+ TODO: Generated by /cpw-startup or defined in Phase 0
@@ -0,0 +1,10 @@
1
+ # Module Interfaces
2
+
3
+ ## Modules
4
+ TODO: Phase 1
5
+
6
+ ## Diagram
7
+ TODO: Step 1.3
8
+
9
+ ## Contracts
10
+ TODO: With src/interfaces/
@@ -0,0 +1,3 @@
1
+ # Tech Debt and Concerns
2
+
3
+ TODO: Generated by /cpw-startup
@@ -0,0 +1,15 @@
1
+ # Skills and MCP Servers
2
+
3
+ ## Installed
4
+
5
+ | Name | Type | Domain | Use in the project | Installed on |
6
+ |------|------|--------|-------------------|-------------|
7
+
8
+ ## Evaluated and discarded
9
+
10
+ | Name | Reason |
11
+ |------|--------|
12
+
13
+ ## Notes
14
+ - Only install what has clear use in the plan
15
+ - Review each phase if something new is needed
@@ -0,0 +1,17 @@
1
+ # claude-pw - session state (always personal)
2
+ STATUS.md
3
+
4
+ # claude-pw - planning (gitignored by default, set commitPlanning: true in .planning/config.json to track)
5
+ .planning/
6
+
7
+ # Claude Code - local config
8
+ .claude/settings.local.json
9
+
10
+ # OS
11
+ .DS_Store
12
+ Thumbs.db
13
+
14
+ # Editors
15
+ *.swp
16
+ *.swo
17
+ *~
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "Pre-commit..."
5
+
6
+ echo " -> Lint..."
7
+ make lint || { echo " x Lint FAILED"; exit 1; }
8
+
9
+ echo " -> Format..."
10
+ make format-check || { echo " x Format FAILED"; exit 1; }
11
+
12
+ echo " -> Types..."
13
+ make typecheck || { echo " x Typecheck FAILED"; exit 1; }
14
+
15
+ echo " -> Tests..."
16
+ make test || { echo " x Tests FAILED"; exit 1; }
17
+
18
+ if [ -d "tests/contracts" ] && [ "$(ls -A tests/contracts 2>/dev/null)" ]; then
19
+ echo " -> Contracts..."
20
+ make test-contracts || { echo " x Contracts FAILED"; exit 1; }
21
+ fi
22
+
23
+ echo "Pre-commit OK"
@@ -0,0 +1,11 @@
1
+ {
2
+ "autoAdvance": "off",
3
+ "granularity": "standard",
4
+ "modelProfile": "balanced",
5
+ "modelOverrides": {},
6
+ "commitPlanning": false,
7
+ "toolingSources": ["skills.sh", "claude-code-templates"],
8
+ "maxConsecutiveFailures": null,
9
+ "gitStrategy": "trunk-based",
10
+ "autoReflect": "remind"
11
+ }
@@ -0,0 +1,3 @@
1
+ # Applied learnings
2
+
3
+ <!-- Format v2: metadata blocks separated by --- -->
@@ -0,0 +1,5 @@
1
+ # Captured corrections
2
+
3
+ <!-- Format v2: metadata blocks separated by --- -->
4
+ <!-- Pattern: explicit (0.90) | guardrail (0.80) | correction (0.70) -->
5
+ <!-- Validated: no (pending) | yes (validated by /cpw-reflect) -->
@@ -0,0 +1,4 @@
1
+ # Quick log & Todos
2
+
3
+ <!-- Format v2: metadata blocks separated by --- -->
4
+ <!-- Status: pending | in-progress | done | dismissed -->
@@ -0,0 +1,9 @@
1
+ # Decisions
2
+
3
+ | # | Phase | Decision | Alternatives | Reason | Impact | Date |
4
+ |---|-------|----------|-------------|--------|--------|------|
5
+
6
+ ## Interface RFCs
7
+
8
+ | # | Module | Change | Status | Date |
9
+ |---|--------|--------|--------|------|
@@ -0,0 +1,57 @@
1
+ # Phase 0: Stack and Scaffolding
2
+
3
+ ## Objective
4
+ Define technologies, structure, toolchain, and environment setup.
5
+
6
+ ## Required context
7
+ - PLAN.md
8
+ - Functional requirements
9
+
10
+ ## Steps
11
+
12
+ ### Step 0.1: Stack definition
13
+ - **Input:** Project requirements. If docs/codebase-map.md exists (from /cpw-startup), use it as a base.
14
+ - **Output:** docs/architecture.md
15
+ - **Done criterion:** Document approved
16
+ - **Status:** [ ]
17
+
18
+ ### Step 0.2: Repo structure
19
+ - **Requires:** 0.1
20
+ - **Input:** docs/architecture.md
21
+ - **Output:** Directories created
22
+ - **Done criterion:** `tree -L 2` matches
23
+ - **Status:** [ ]
24
+
25
+ ### Step 0.3: Skills and MCPs
26
+ - **Requires:** 0.1, 0.2
27
+ - **Input:** docs/architecture.md, defined stack, identified modules
28
+ - **Output:** List of installed skills/MCPs, docs/tooling.md with justification
29
+ - **Done criterion:** Skills/MCPs installed and verified working
30
+ - **Status:** [ ]
31
+ - **Notes:** Evaluate skills and MCP servers that accelerate development based on the project domain. Search by domain (e.g.: admin UI, video processing, DB management), do NOT overload -- only what has clear use in the plan. Document what was installed and why.
32
+
33
+ ### Step 0.4: Makefile + toolchain + changelog auto-gen
34
+ - **Requires:** 0.3
35
+ - **Input:** Stack + structure + installed skills
36
+ - **Output:** Makefile, lint/format/test configs, changelog tooling
37
+ - **Done criterion:** `make lint`, `make test`, `make build` OK
38
+ - **Status:** [ ]
39
+
40
+ ### Step 0.5: Pre-commit + CI/CD + versioning
41
+ - **Requires:** 0.4
42
+ - **Input:** Configured toolchain
43
+ - **Output:** Pre-commit hook, CI pipeline, semver
44
+ - **Done criterion:** Pre-commit blocks broken commits, CI runs on push
45
+ - **Status:** [ ]
46
+
47
+ ### Step 0.6: Setup Claude Code
48
+ - **Requires:** 0.5
49
+ - **Input:** All of the above
50
+ - **Output:** CLAUDE.md, rules, commands, agents adjusted to the actual stack
51
+ - **Done criterion:** /cpw-next-step works
52
+ - **Status:** [ ]
53
+
54
+ ## Gate
55
+ - [ ] `make check` passes
56
+ - [ ] Pre-commit blocks broken commits
57
+ - [ ] Claude Code tooling functional
@@ -0,0 +1,49 @@
1
+ # Phase 1: Interfaces and Modules
2
+
3
+ ## Objective
4
+ Define modules, interfaces, and contracts before implementing.
5
+
6
+ ## Required context
7
+ - docs/architecture.md
8
+ - PLAN.md
9
+
10
+ ## Steps
11
+
12
+ ### Step 1.1: Module identification
13
+ - **Input:** Requirements + architecture.md
14
+ - **Output:** List in docs/interfaces.md
15
+ - **Done criterion:** Modules with name, responsibility, boundaries
16
+ - **Status:** [ ]
17
+
18
+ ### Step 1.2: Public interfaces
19
+ - **Requires:** 1.1
20
+ - **Input:** List of modules
21
+ - **Output:** src/interfaces/ (one per module)
22
+ - **Done criterion:** Compiles, strict types
23
+ - **Status:** [ ]
24
+
25
+ ### Step 1.3: Contracts between modules
26
+ - **Requires:** 1.2
27
+ - **Input:** Interfaces
28
+ - **Output:** Diagram in docs/
29
+ - **Done criterion:** No circular deps
30
+ - **Status:** [ ]
31
+
32
+ ### Step 1.4: Contract tests
33
+ - **Requires:** 1.3
34
+ - **Input:** Interfaces
35
+ - **Output:** tests/contracts/ with stubs
36
+ - **Done criterion:** `make test-contracts` passes
37
+ - **Status:** [ ]
38
+
39
+ ### Step 1.5: Interface lock
40
+ - **Requires:** 1.4
41
+ - **Input:** All
42
+ - **Output:** Interfaces in main, active RFC
43
+ - **Done criterion:** Merged
44
+ - **Status:** [ ]
45
+
46
+ ## Gate
47
+ - [ ] Interfaces compile
48
+ - [ ] Contract tests pass
49
+ - [ ] docs/interfaces.md complete