cc-discipline 2.10.0 → 2.10.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 (45) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +153 -153
  3. package/README.zh-CN.md +207 -207
  4. package/bin/cli.js +147 -147
  5. package/bin/cli.sh +96 -96
  6. package/global/CLAUDE.md +45 -45
  7. package/init.sh +594 -594
  8. package/lib/doctor.sh +145 -145
  9. package/lib/stack-remove.sh +68 -68
  10. package/lib/status.sh +100 -100
  11. package/package.json +34 -34
  12. package/templates/.claude/agents/investigator.md +44 -44
  13. package/templates/.claude/agents/reviewer.md +46 -46
  14. package/templates/.claude/hooks/action-counter.sh +58 -58
  15. package/templates/.claude/hooks/git-guard.sh +62 -62
  16. package/templates/.claude/hooks/phase-gate.sh +10 -10
  17. package/templates/.claude/hooks/post-error-remind.sh +114 -114
  18. package/templates/.claude/hooks/pre-edit-guard.sh +100 -100
  19. package/templates/.claude/hooks/session-start.sh +44 -44
  20. package/templates/.claude/hooks/streak-breaker.sh +111 -111
  21. package/templates/.claude/rules/00-core-principles.md +16 -16
  22. package/templates/.claude/rules/01-debugging.md +32 -32
  23. package/templates/.claude/rules/02-before-edit.md +22 -22
  24. package/templates/.claude/rules/03-context-mgmt.md +44 -44
  25. package/templates/.claude/rules/04-no-mole-whacking.md +26 -26
  26. package/templates/.claude/rules/05-phase-discipline.md +15 -15
  27. package/templates/.claude/rules/06-multi-task.md +12 -12
  28. package/templates/.claude/rules/07-integrity.md +92 -92
  29. package/templates/.claude/rules/stacks/embedded.md +24 -24
  30. package/templates/.claude/rules/stacks/js-ts.md +21 -21
  31. package/templates/.claude/rules/stacks/mobile.md +16 -16
  32. package/templates/.claude/rules/stacks/python.md +20 -20
  33. package/templates/.claude/rules/stacks/rtl.md +24 -24
  34. package/templates/.claude/settings.json +84 -84
  35. package/templates/.claude/skills/commit/SKILL.md +40 -40
  36. package/templates/.claude/skills/evaluate/SKILL.md +57 -57
  37. package/templates/.claude/skills/investigate/SKILL.md +192 -192
  38. package/templates/.claude/skills/retro/SKILL.md +40 -40
  39. package/templates/.claude/skills/self-check/SKILL.md +87 -82
  40. package/templates/.claude/skills/summary/SKILL.md +48 -48
  41. package/templates/.claude/skills/think/SKILL.md +108 -108
  42. package/templates/CLAUDE.md +96 -96
  43. package/templates/docs/debug-log.md +48 -48
  44. package/templates/docs/progress.md +72 -72
  45. package/templates/memory/MEMORY.md +23 -23
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 TechHU
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 TechHU
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,153 +1,153 @@
1
- # cc-discipline
2
-
3
- Guardrails for Claude Code. Shell hooks that **actually block** bad behavior, not just markdown that asks nicely.
4
-
5
- [中文文档](README.zh-CN.md)
6
-
7
- ## The Problem
8
-
9
- Claude Code in long sessions tends to:
10
- - Edit the same file 5+ times chasing symptoms instead of finding root cause
11
- - See an error and immediately change code without understanding it
12
- - Lose track of what it was doing after context compaction
13
-
14
- Markdown rules help, but Claude can ignore them. **Hooks can't be ignored** — they run as shell scripts and `exit 2` physically blocks the operation.
15
-
16
- ## What This Does
17
-
18
- ### Hooks (the enforcer)
19
-
20
- Three shell scripts that run automatically before/after Claude's actions:
21
-
22
- **`streak-breaker.sh`** — Tracks per-file edit counts. Warns at 3, **hard-blocks at 5**. Forces Claude to stop and find the root cause instead of endlessly patching.
23
-
24
- ```
25
- MOLE-WHACKING ALERT (hard stop)
26
- File src/auth.py has been edited 5 times.
27
- You are repeatedly patching symptoms instead of solving the root cause.
28
- Required actions:
29
- 1. Stop editing this file immediately
30
- 2. Review the purpose of all 5 edits
31
- 3. Look for the common root cause
32
- 4. Report findings to the user and wait for guidance
33
- ```
34
-
35
- **`pre-edit-guard.sh`** — Checks `docs/debug-log.md` for unverified hypotheses. If you're debugging and haven't finished the process, it blocks source code edits until you do.
36
-
37
- **`post-error-remind.sh`** — Detects error patterns (test failures, crashes, build errors) in command output and injects a debugging discipline reminder before Claude can react impulsively.
38
-
39
- ### Rules (the reminders)
40
-
41
- Auto-injected markdown in `.claude/rules/` — Claude sees them when operating on matching files. Not as strong as hooks, but provides structure:
42
-
43
- - Debugging process: gather → hypothesize → verify → fix (no skipping)
44
- - Pre-edit checklist: understand the file, know the impact, fix root cause
45
- - Mole-whacking detection: recognize the pattern, stop, report
46
- - Phase discipline: stay in research/plan/implement, don't jump ahead
47
- - Multi-task gates: complete tasks in order, confirm each before moving on
48
- - Tech stack rules for Python, JS/TS, embedded, RTL, mobile
49
-
50
- ### Subagents (the auditors)
51
-
52
- - **reviewer** — Reviews your modification plan in a separate context. Challenges assumptions, suggests alternatives, checks for missing edge cases.
53
- - **investigator** — Researches the codebase in isolation. Returns structured findings without polluting your main conversation.
54
-
55
- ## Install
56
-
57
- ```bash
58
- git clone https://github.com/TechHU-GS/cc-discipline.git ~/.cc-discipline
59
- cd your-project
60
- bash ~/.cc-discipline/init.sh
61
- ```
62
-
63
- The installer is interactive — pick your tech stack, name your project, done.
64
-
65
- **Already have a `.claude/` setup?** The installer detects this and runs in append mode:
66
- - Your `CLAUDE.md` is **never overwritten**
67
- - Your `settings.json` hooks are **preserved** (cc-discipline hooks are merged in via `jq`)
68
- - Your custom rules, agents, and docs are **untouched**
69
- - A timestamped backup is created before any changes
70
-
71
- **Upgrading?** Just run `init.sh` again. It detects the existing installation and updates framework files while preserving your configuration.
72
-
73
- ## What Gets Installed
74
-
75
- ```
76
- .claude/
77
- ├── rules/ # Auto-injected when Claude operates on matching files
78
- │ ├── 00-core-principles.md
79
- │ ├── 01-debugging.md
80
- │ ├── 02-before-edit.md
81
- │ ├── 03-context-mgmt.md
82
- │ ├── 04-no-mole-whacking.md
83
- │ ├── 05-phase-discipline.md
84
- │ ├── 06-multi-task.md
85
- │ └── stacks/ # Picked during install
86
- ├── hooks/ # Shell scripts, exit 2 = block operation
87
- │ ├── streak-breaker.sh
88
- │ ├── pre-edit-guard.sh
89
- │ └── post-error-remind.sh
90
- ├── agents/
91
- │ ├── reviewer.md
92
- │ └── investigator.md
93
- ├── skills/
94
- │ └── commit/SKILL.md # /commit: test → update docs → commit
95
- └── settings.json # Hook registration
96
- docs/
97
- ├── progress.md # Claude maintains this, read after compact
98
- └── debug-log.md # Debug session tracking
99
- CLAUDE.md # Your project info (you fill this in)
100
- ```
101
-
102
- ## Customization
103
-
104
- **Adjust hook strictness:**
105
-
106
- ```bash
107
- # In .claude/hooks/streak-breaker.sh
108
- WARN_THRESHOLD=3 # Warn after N edits to same file
109
- STOP_THRESHOLD=5 # Hard block after N edits
110
- ```
111
-
112
- **Add your own rules:**
113
-
114
- ```bash
115
- cat > .claude/rules/my-rule.md << 'EOF'
116
- ---
117
- globs: "src/api/**/*"
118
- description: "API layer rules"
119
- ---
120
- - All API changes must be backwards-compatible
121
- - New endpoints need OpenAPI spec updates
122
- EOF
123
- ```
124
-
125
- **Write your own hooks:**
126
-
127
- Any script in `.claude/hooks/` can be registered in `settings.json`. The key behaviors:
128
- - `exit 0` = allow (stdout can inject context via JSON for PreToolUse hooks)
129
- - `exit 2` + stderr = block operation, stderr message shown to Claude
130
-
131
- See [Claude Code hooks docs](https://docs.anthropic.com/en/docs/claude-code/hooks) for the full spec.
132
-
133
- ## FAQ
134
-
135
- **Is this just markdown rules?**
136
- No. The hooks are the real enforcement — they're shell scripts that physically block operations. The rules are supplementary structure.
137
-
138
- **Does it slow things down?**
139
- No. Hooks are lightweight shell scripts, typically <100ms. Rules add ~8KB to context (~2%).
140
-
141
- **Should I commit `.claude/` to git?**
142
- Yes. Team members get the same guardrails. Hook paths use `$CLAUDE_PROJECT_DIR`, so they work across machines.
143
-
144
- **Does it work with existing projects?**
145
- Yes. The installer has an append mode that merges with your existing `.claude/` configuration without overwriting anything. Run `init.sh` and it auto-detects.
146
-
147
- ## Contributing
148
-
149
- PRs welcome — especially new hooks. The hooks are where the real value is.
150
-
151
- ## License
152
-
153
- [MIT](LICENSE)
1
+ # cc-discipline
2
+
3
+ Guardrails for Claude Code. Shell hooks that **actually block** bad behavior, not just markdown that asks nicely.
4
+
5
+ [中文文档](README.zh-CN.md)
6
+
7
+ ## The Problem
8
+
9
+ Claude Code in long sessions tends to:
10
+ - Edit the same file 5+ times chasing symptoms instead of finding root cause
11
+ - See an error and immediately change code without understanding it
12
+ - Lose track of what it was doing after context compaction
13
+
14
+ Markdown rules help, but Claude can ignore them. **Hooks can't be ignored** — they run as shell scripts and `exit 2` physically blocks the operation.
15
+
16
+ ## What This Does
17
+
18
+ ### Hooks (the enforcer)
19
+
20
+ Three shell scripts that run automatically before/after Claude's actions:
21
+
22
+ **`streak-breaker.sh`** — Tracks per-file edit counts. Warns at 3, **hard-blocks at 5**. Forces Claude to stop and find the root cause instead of endlessly patching.
23
+
24
+ ```
25
+ MOLE-WHACKING ALERT (hard stop)
26
+ File src/auth.py has been edited 5 times.
27
+ You are repeatedly patching symptoms instead of solving the root cause.
28
+ Required actions:
29
+ 1. Stop editing this file immediately
30
+ 2. Review the purpose of all 5 edits
31
+ 3. Look for the common root cause
32
+ 4. Report findings to the user and wait for guidance
33
+ ```
34
+
35
+ **`pre-edit-guard.sh`** — Checks `docs/debug-log.md` for unverified hypotheses. If you're debugging and haven't finished the process, it blocks source code edits until you do.
36
+
37
+ **`post-error-remind.sh`** — Detects error patterns (test failures, crashes, build errors) in command output and injects a debugging discipline reminder before Claude can react impulsively.
38
+
39
+ ### Rules (the reminders)
40
+
41
+ Auto-injected markdown in `.claude/rules/` — Claude sees them when operating on matching files. Not as strong as hooks, but provides structure:
42
+
43
+ - Debugging process: gather → hypothesize → verify → fix (no skipping)
44
+ - Pre-edit checklist: understand the file, know the impact, fix root cause
45
+ - Mole-whacking detection: recognize the pattern, stop, report
46
+ - Phase discipline: stay in research/plan/implement, don't jump ahead
47
+ - Multi-task gates: complete tasks in order, confirm each before moving on
48
+ - Tech stack rules for Python, JS/TS, embedded, RTL, mobile
49
+
50
+ ### Subagents (the auditors)
51
+
52
+ - **reviewer** — Reviews your modification plan in a separate context. Challenges assumptions, suggests alternatives, checks for missing edge cases.
53
+ - **investigator** — Researches the codebase in isolation. Returns structured findings without polluting your main conversation.
54
+
55
+ ## Install
56
+
57
+ ```bash
58
+ git clone https://github.com/TechHU-GS/cc-discipline.git ~/.cc-discipline
59
+ cd your-project
60
+ bash ~/.cc-discipline/init.sh
61
+ ```
62
+
63
+ The installer is interactive — pick your tech stack, name your project, done.
64
+
65
+ **Already have a `.claude/` setup?** The installer detects this and runs in append mode:
66
+ - Your `CLAUDE.md` is **never overwritten**
67
+ - Your `settings.json` hooks are **preserved** (cc-discipline hooks are merged in via `jq`)
68
+ - Your custom rules, agents, and docs are **untouched**
69
+ - A timestamped backup is created before any changes
70
+
71
+ **Upgrading?** Just run `init.sh` again. It detects the existing installation and updates framework files while preserving your configuration.
72
+
73
+ ## What Gets Installed
74
+
75
+ ```
76
+ .claude/
77
+ ├── rules/ # Auto-injected when Claude operates on matching files
78
+ │ ├── 00-core-principles.md
79
+ │ ├── 01-debugging.md
80
+ │ ├── 02-before-edit.md
81
+ │ ├── 03-context-mgmt.md
82
+ │ ├── 04-no-mole-whacking.md
83
+ │ ├── 05-phase-discipline.md
84
+ │ ├── 06-multi-task.md
85
+ │ └── stacks/ # Picked during install
86
+ ├── hooks/ # Shell scripts, exit 2 = block operation
87
+ │ ├── streak-breaker.sh
88
+ │ ├── pre-edit-guard.sh
89
+ │ └── post-error-remind.sh
90
+ ├── agents/
91
+ │ ├── reviewer.md
92
+ │ └── investigator.md
93
+ ├── skills/
94
+ │ └── commit/SKILL.md # /commit: test → update docs → commit
95
+ └── settings.json # Hook registration
96
+ docs/
97
+ ├── progress.md # Claude maintains this, read after compact
98
+ └── debug-log.md # Debug session tracking
99
+ CLAUDE.md # Your project info (you fill this in)
100
+ ```
101
+
102
+ ## Customization
103
+
104
+ **Adjust hook strictness:**
105
+
106
+ ```bash
107
+ # In .claude/hooks/streak-breaker.sh
108
+ WARN_THRESHOLD=3 # Warn after N edits to same file
109
+ STOP_THRESHOLD=5 # Hard block after N edits
110
+ ```
111
+
112
+ **Add your own rules:**
113
+
114
+ ```bash
115
+ cat > .claude/rules/my-rule.md << 'EOF'
116
+ ---
117
+ globs: "src/api/**/*"
118
+ description: "API layer rules"
119
+ ---
120
+ - All API changes must be backwards-compatible
121
+ - New endpoints need OpenAPI spec updates
122
+ EOF
123
+ ```
124
+
125
+ **Write your own hooks:**
126
+
127
+ Any script in `.claude/hooks/` can be registered in `settings.json`. The key behaviors:
128
+ - `exit 0` = allow (stdout can inject context via JSON for PreToolUse hooks)
129
+ - `exit 2` + stderr = block operation, stderr message shown to Claude
130
+
131
+ See [Claude Code hooks docs](https://docs.anthropic.com/en/docs/claude-code/hooks) for the full spec.
132
+
133
+ ## FAQ
134
+
135
+ **Is this just markdown rules?**
136
+ No. The hooks are the real enforcement — they're shell scripts that physically block operations. The rules are supplementary structure.
137
+
138
+ **Does it slow things down?**
139
+ No. Hooks are lightweight shell scripts, typically <100ms. Rules add ~8KB to context (~2%).
140
+
141
+ **Should I commit `.claude/` to git?**
142
+ Yes. Team members get the same guardrails. Hook paths use `$CLAUDE_PROJECT_DIR`, so they work across machines.
143
+
144
+ **Does it work with existing projects?**
145
+ Yes. The installer has an append mode that merges with your existing `.claude/` configuration without overwriting anything. Run `init.sh` and it auto-detects.
146
+
147
+ ## Contributing
148
+
149
+ PRs welcome — especially new hooks. The hooks are where the real value is.
150
+
151
+ ## License
152
+
153
+ [MIT](LICENSE)