cc-discipline 2.10.2 → 2.10.3
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.
- package/README.md +91 -8
- package/README.zh-CN.md +93 -1
- package/global/CLAUDE.md +1 -1
- package/package.json +3 -3
- package/templates/.claude/skills/self-check/SKILL.md +27 -2
package/README.md
CHANGED
|
@@ -21,21 +21,104 @@ Three shell scripts that run automatically before/after Claude's actions:
|
|
|
21
21
|
|
|
22
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
23
|
|
|
24
|
+
Here's what it looks like in practice:
|
|
25
|
+
|
|
24
26
|
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
You: "Fix the login validation bug in auth.py"
|
|
28
|
+
|
|
29
|
+
Claude: I'll fix the validation logic.
|
|
30
|
+
[Edit src/auth.py — fix email regex]
|
|
31
|
+
|
|
32
|
+
Claude: The regex wasn't enough, let me also add length check.
|
|
33
|
+
[Edit src/auth.py — add input length validation]
|
|
34
|
+
|
|
35
|
+
Claude: That broke the existing tests, let me adjust.
|
|
36
|
+
[Edit src/auth.py — fix test compatibility]
|
|
37
|
+
⚠️ EDIT NOTE: File src/auth.py has been edited 3 times.
|
|
38
|
+
Quick check: are these edits building toward a goal,
|
|
39
|
+
or fixing previous edits?
|
|
40
|
+
|
|
41
|
+
Claude: Let me try a different approach to the validation.
|
|
42
|
+
[Edit src/auth.py — rewrite validation layer]
|
|
43
|
+
|
|
44
|
+
Claude: Almost there, one more adjustment...
|
|
45
|
+
[Edit src/auth.py — blocked]
|
|
46
|
+
|
|
47
|
+
🛑 EDIT CHECKPOINT
|
|
48
|
+
File src/auth.py has been edited 5 times this session.
|
|
49
|
+
Reflect:
|
|
50
|
+
1. Are these edits progressing toward a goal,
|
|
51
|
+
or fixing previous edits?
|
|
52
|
+
2. If fixing previous edits: pause and look
|
|
53
|
+
for the root cause.
|
|
54
|
+
|
|
55
|
+
Claude: You're right. Looking at all 5 edits, I was patching
|
|
56
|
+
symptoms. The real issue is that the User model's
|
|
57
|
+
validate() method is called before sanitization.
|
|
58
|
+
Let me fix it at the source instead.
|
|
33
59
|
```
|
|
34
60
|
|
|
61
|
+
Without the hook, Claude would keep editing `auth.py` indefinitely — each fix creating the next bug. The hook forces a pause that leads to root-cause discovery.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
35
65
|
**`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
66
|
|
|
67
|
+
```
|
|
68
|
+
You: "The API is returning 500 errors on /users endpoint"
|
|
69
|
+
|
|
70
|
+
Claude: Let me investigate.
|
|
71
|
+
[Bash: curl localhost:3000/users]
|
|
72
|
+
→ 500 Internal Server Error
|
|
73
|
+
|
|
74
|
+
Claude: I think it's a database connection issue. Let me fix
|
|
75
|
+
the connection pool config.
|
|
76
|
+
[Edit src/db.py — blocked]
|
|
77
|
+
|
|
78
|
+
🛑 docs/debug-log.md has 2 unverified hypotheses.
|
|
79
|
+
Please complete the debugging process (verify or
|
|
80
|
+
eliminate hypotheses) before editing source code.
|
|
81
|
+
|
|
82
|
+
Claude: Right, I haven't verified my hypothesis yet.
|
|
83
|
+
Let me check the actual error logs first.
|
|
84
|
+
[Bash: tail -50 logs/error.log]
|
|
85
|
+
→ TypeError: Cannot read property 'map' of undefined
|
|
86
|
+
at UserSerializer.format (src/serializers.py:42)
|
|
87
|
+
|
|
88
|
+
Claude: The error is in the serializer, not the database.
|
|
89
|
+
My first hypothesis was wrong. Let me update
|
|
90
|
+
debug-log.md and then fix the actual issue.
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Without the hook, Claude would have "fixed" the database config — a perfectly working component — and the real bug would remain.
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
37
97
|
**`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
98
|
|
|
99
|
+
```
|
|
100
|
+
Claude: Let me run the tests.
|
|
101
|
+
[Bash: pytest tests/]
|
|
102
|
+
→ FAILED tests/test_auth.py::test_login - AssertionError
|
|
103
|
+
→ 1 failed, 23 passed
|
|
104
|
+
|
|
105
|
+
⚡ Error encountered — debugging checklist:
|
|
106
|
+
1. Resist modifying code immediately
|
|
107
|
+
2. Fully understand the error message
|
|
108
|
+
3. List >=3 possible causes
|
|
109
|
+
4. Only then fix
|
|
110
|
+
|
|
111
|
+
Claude: Before jumping in, let me understand the failure.
|
|
112
|
+
The test expects a 200 but gets 401. Three possible
|
|
113
|
+
causes:
|
|
114
|
+
1. Token generation changed (check auth.py changes)
|
|
115
|
+
2. Test fixture uses expired mock token
|
|
116
|
+
3. Middleware order changed after recent refactor
|
|
117
|
+
Let me verify each...
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Without the hook, Claude's instinct is to immediately open the test or source file and start editing. The reminder forces a diagnostic pause.
|
|
121
|
+
|
|
39
122
|
### Rules (the reminders)
|
|
40
123
|
|
|
41
124
|
Auto-injected markdown in `.claude/rules/` — Claude sees them when operating on matching files. Not as strong as hooks, but provides structure:
|
package/README.zh-CN.md
CHANGED
|
@@ -127,10 +127,102 @@ Hooks 是在 Claude 执行操作前/后自动运行的 shell 脚本。**exit 2
|
|
|
127
127
|
|
|
128
128
|
| Hook | 触发时机 | 作用 |
|
|
129
129
|
|------|---------|------|
|
|
130
|
-
| `pre-edit-guard.sh` | 编辑文件前 | 检查是否有未完成的调试流程 |
|
|
131
130
|
| `streak-breaker.sh` | 编辑文件前 | 同文件编辑 ≥3 次警告,≥5 次硬停止 |
|
|
131
|
+
| `pre-edit-guard.sh` | 编辑文件前 | 检查是否有未完成的调试流程 |
|
|
132
132
|
| `post-error-remind.sh` | 执行命令后 | 检测到错误输出时提醒遵守调试纪律 |
|
|
133
133
|
|
|
134
|
+
**实际效果演示:**
|
|
135
|
+
|
|
136
|
+
**streak-breaker** — 阻止打地鼠:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
你: "修一下 auth.py 的登录验证 bug"
|
|
140
|
+
|
|
141
|
+
Claude: 我来修正验证逻辑。
|
|
142
|
+
[编辑 src/auth.py — 修正邮箱正则]
|
|
143
|
+
|
|
144
|
+
Claude: 正则不够,再加个长度检查。
|
|
145
|
+
[编辑 src/auth.py — 增加输入长度验证]
|
|
146
|
+
|
|
147
|
+
Claude: 把之前的测试搞挂了,调整一下。
|
|
148
|
+
[编辑 src/auth.py — 修复测试兼容性]
|
|
149
|
+
⚠️ 提示:auth.py 已被编辑 3 次。
|
|
150
|
+
检查一下:这些修改是在推进目标,还是在修前面的修改?
|
|
151
|
+
|
|
152
|
+
Claude: 换个思路重写验证层。
|
|
153
|
+
[编辑 src/auth.py — 重写验证逻辑]
|
|
154
|
+
|
|
155
|
+
Claude: 差不多了,再调一下...
|
|
156
|
+
[编辑 src/auth.py — 被阻止]
|
|
157
|
+
|
|
158
|
+
🛑 编辑检查点
|
|
159
|
+
文件 auth.py 本次会话已被编辑 5 次。
|
|
160
|
+
反思:
|
|
161
|
+
1. 这些修改是在推进目标,还是在修之前的修改?
|
|
162
|
+
2. 如果是后者:停下来,寻找根本原因。
|
|
163
|
+
|
|
164
|
+
Claude: 你说得对。回顾这 5 次编辑,我一直在修症状。
|
|
165
|
+
真正的问题是 User 模型的 validate() 在
|
|
166
|
+
sanitization 之前被调用了。我应该从源头修。
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
没有这个 hook,Claude 会无限编辑 auth.py — 每次修复都制造下一个 bug。hook 强制暂停,引导发现根本原因。
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
**pre-edit-guard** — 阻止跳过诊断直接改代码:
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
你: "API 的 /users 接口返回 500 错误"
|
|
177
|
+
|
|
178
|
+
Claude: 我来排查。
|
|
179
|
+
[执行: curl localhost:3000/users]
|
|
180
|
+
→ 500 Internal Server Error
|
|
181
|
+
|
|
182
|
+
Claude: 我觉得是数据库连接池的问题,改一下配置。
|
|
183
|
+
[编辑 src/db.py — 被阻止]
|
|
184
|
+
|
|
185
|
+
🛑 docs/debug-log.md 中有 2 个未验证的假设。
|
|
186
|
+
请先完成调试流程(验证或排除假设),
|
|
187
|
+
再编辑源代码。
|
|
188
|
+
|
|
189
|
+
Claude: 对,我还没验证我的假设。先看看错误日志。
|
|
190
|
+
[执行: tail -50 logs/error.log]
|
|
191
|
+
→ TypeError: Cannot read property 'map' of undefined
|
|
192
|
+
at UserSerializer.format (src/serializers.py:42)
|
|
193
|
+
|
|
194
|
+
Claude: 错误在序列化器,不是数据库。我的第一个
|
|
195
|
+
假设是错的。先更新 debug-log.md 再修真正的问题。
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
没有这个 hook,Claude 会"修好"数据库配置 — 一个完全正常的组件 — 而真正的 bug 依然存在。
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
**post-error-remind** — 阻止看到报错就冲动改代码:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
Claude: 跑一下测试。
|
|
206
|
+
[执行: pytest tests/]
|
|
207
|
+
→ FAILED tests/test_auth.py::test_login - AssertionError
|
|
208
|
+
→ 1 failed, 23 passed
|
|
209
|
+
|
|
210
|
+
⚡ 检测到错误 — 调试清单:
|
|
211
|
+
1. 不要立即修改代码
|
|
212
|
+
2. 先完整理解错误信息
|
|
213
|
+
3. 列出 ≥3 个可能原因
|
|
214
|
+
4. 然后再动手
|
|
215
|
+
|
|
216
|
+
Claude: 先别急着改。测试期望 200 但拿到了 401。
|
|
217
|
+
三个可能原因:
|
|
218
|
+
1. Token 生成逻辑变了(检查 auth.py 的改动)
|
|
219
|
+
2. 测试用的 mock token 过期了
|
|
220
|
+
3. 中间件顺序在最近的重构后变了
|
|
221
|
+
让我逐个验证...
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
没有这个 hook,Claude 的本能是立即打开测试文件或源文件开始编辑。提醒强制了一个诊断暂停。
|
|
225
|
+
|
|
134
226
|
**调整硬度**:编辑 hook 脚本中的 `exit` 返回值:
|
|
135
227
|
- `exit 0` = 允许操作(可附带提醒信息)
|
|
136
228
|
- `exit 1` = 报错但不阻止操作(hook 执行失败)
|
package/global/CLAUDE.md
CHANGED
|
@@ -41,5 +41,5 @@ Don't skip the first three steps and jump straight to the fourth.
|
|
|
41
41
|
|
|
42
42
|
- Use subagents for research. Don't read large volumes of files in the main conversation.
|
|
43
43
|
- Update docs/progress.md after completing each milestone.
|
|
44
|
-
-
|
|
44
|
+
- Don't proactively warn about context running low or suggest compacting. The system auto-compacts at 0% — you cannot see the percentage. Keep progress.md updated instead.
|
|
45
45
|
- First thing after compact: read `docs/progress.md` and `docs/debug-log.md`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cc-discipline",
|
|
3
|
-
"version": "2.10.
|
|
3
|
+
"version": "2.10.3",
|
|
4
4
|
"description": "Discipline framework for Claude Code — rules, hooks, and agents that keep AI on track",
|
|
5
5
|
"bin": {
|
|
6
6
|
"cc-discipline": "bin/cli.js"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
|
-
"url": "git+https://github.com/
|
|
31
|
+
"url": "git+https://github.com/TechHU-GS/cc-discipline.git"
|
|
32
32
|
},
|
|
33
|
-
"homepage": "https://github.com/
|
|
33
|
+
"homepage": "https://github.com/TechHU-GS/cc-discipline#readme"
|
|
34
34
|
}
|
|
@@ -61,11 +61,35 @@ Pause and honestly answer every question below.
|
|
|
61
61
|
|
|
62
62
|
If any of the above are stale or incomplete: **update docs/progress.md now before continuing.** This takes 2 minutes and saves hours of re-discovery after compact.
|
|
63
63
|
|
|
64
|
-
## 6.
|
|
64
|
+
## 6. Am I using the project's scaffolding?
|
|
65
|
+
|
|
66
|
+
Projects accumulate custom tooling — audit scripts, lint configs, validators (cppcheck, custom DRC, schema checkers, etc.). These get forgotten and rot if not exercised.
|
|
67
|
+
|
|
68
|
+
- Check **CLAUDE.md "Project Tools"** and the **Project-specific Checks** list below. Are any relevant to current work but haven't been run?
|
|
69
|
+
- Did I build a new tool/script/check this session that future sessions should know about? If yes, **register it now in two places**:
|
|
70
|
+
1. `CLAUDE.md` "Project Tools" — what it is, where it lives, when to use it
|
|
71
|
+
2. The **Project-specific Checks** list below — so the next /self-check surfaces it automatically
|
|
72
|
+
- If the **Project-specific Checks** list below is empty or stale, that's a signal worth raising with the user.
|
|
73
|
+
|
|
74
|
+
### Project-specific Checks
|
|
75
|
+
|
|
76
|
+
<!--
|
|
77
|
+
Add project-specific scaffolding here. One line per check, format:
|
|
78
|
+
- `<command>` — when to run / what it catches
|
|
79
|
+
Examples:
|
|
80
|
+
- `make lint` — before commit, catches license headers and formatting
|
|
81
|
+
- `python tools/audit_rbac.py` — after schema changes, catches RBAC drift
|
|
82
|
+
- `cppcheck src/` — after C/C++ edits, catches null deref / leak patterns
|
|
83
|
+
Keep this list curated — remove tools that are obsolete.
|
|
84
|
+
-->
|
|
85
|
+
|
|
86
|
+
(Empty — fill in as the project develops scaffolding worth checking periodically.)
|
|
87
|
+
|
|
88
|
+
## 7. What's working well?
|
|
65
89
|
|
|
66
90
|
Before reporting issues, note one thing that's going well — a good approach, a clean fix, effective tool use, or strong alignment with the user's direction. Recognizing what works reinforces it.
|
|
67
91
|
|
|
68
|
-
##
|
|
92
|
+
## 8. Status report
|
|
69
93
|
|
|
70
94
|
After answering the above, output a brief status:
|
|
71
95
|
|
|
@@ -76,6 +100,7 @@ Current action: [what I'm doing now]
|
|
|
76
100
|
On track: yes/no/drifted
|
|
77
101
|
Progressing: yes/circling
|
|
78
102
|
Progress recorded: yes/updated now/no
|
|
103
|
+
Scaffolding: [used/skipped/n/a]
|
|
79
104
|
Going well: [one thing]
|
|
80
105
|
Issues found: [list, or "none"]
|
|
81
106
|
```
|