claude-jacked 0.2.7__py3-none-any.whl → 0.3.0__py3-none-any.whl
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.
- claude_jacked-0.3.0.dist-info/METADATA +667 -0
- claude_jacked-0.3.0.dist-info/RECORD +33 -0
- jacked/__init__.py +34 -14
- jacked/cli.py +513 -60
- jacked/client.py +78 -28
- jacked/data/agents/double-check-reviewer.md +42 -0
- jacked/data/commands/audit-rules.md +103 -0
- jacked/data/commands/dc.md +36 -3
- jacked/data/commands/learn.md +89 -0
- jacked/data/commands/redo.md +85 -0
- jacked/data/commands/techdebt.md +115 -0
- jacked/data/hooks/security_gatekeeper.py +415 -0
- jacked/data/rules/jacked_behaviors.md +11 -0
- jacked/index_write_tracker.py +227 -0
- jacked/indexer.py +189 -163
- jacked/searcher.py +4 -0
- claude_jacked-0.2.7.dist-info/METADATA +0 -580
- claude_jacked-0.2.7.dist-info/RECORD +0 -26
- {claude_jacked-0.2.7.dist-info → claude_jacked-0.3.0.dist-info}/WHEEL +0 -0
- {claude_jacked-0.2.7.dist-info → claude_jacked-0.3.0.dist-info}/entry_points.txt +0 -0
- {claude_jacked-0.2.7.dist-info → claude_jacked-0.3.0.dist-info}/licenses/LICENSE +0 -0
jacked/client.py
CHANGED
|
@@ -55,11 +55,13 @@ class QdrantSessionClient:
|
|
|
55
55
|
|
|
56
56
|
def ensure_collection(self) -> bool:
|
|
57
57
|
"""
|
|
58
|
-
Ensure the collection exists
|
|
58
|
+
Ensure the collection exists with all required indexes.
|
|
59
59
|
|
|
60
60
|
Creates collection with:
|
|
61
61
|
- Dense vectors for semantic search
|
|
62
|
-
- Payload indexing for
|
|
62
|
+
- Payload indexing for filtering
|
|
63
|
+
|
|
64
|
+
Also ensures indexes exist on existing collections (for upgrades).
|
|
63
65
|
|
|
64
66
|
Returns:
|
|
65
67
|
True if collection exists or was created
|
|
@@ -75,7 +77,9 @@ class QdrantSessionClient:
|
|
|
75
77
|
exists = any(c.name == collection_name for c in collections.collections)
|
|
76
78
|
|
|
77
79
|
if exists:
|
|
78
|
-
logger.
|
|
80
|
+
logger.debug(f"Collection '{collection_name}' already exists")
|
|
81
|
+
# Ensure indexes exist (handles upgrades)
|
|
82
|
+
self._ensure_indexes(collection_name)
|
|
79
83
|
return True
|
|
80
84
|
|
|
81
85
|
logger.info(f"Creating collection '{collection_name}'")
|
|
@@ -134,6 +138,30 @@ class QdrantSessionClient:
|
|
|
134
138
|
logger.error(f"Failed to create collection: {e}")
|
|
135
139
|
raise
|
|
136
140
|
|
|
141
|
+
def _ensure_indexes(self, collection_name: str):
|
|
142
|
+
"""
|
|
143
|
+
Ensure all required payload indexes exist on a collection.
|
|
144
|
+
|
|
145
|
+
Creates indexes if they don't exist (idempotent).
|
|
146
|
+
"""
|
|
147
|
+
required_indexes = [
|
|
148
|
+
"repo_id", "repo_name", "session_id", "type",
|
|
149
|
+
"machine", "user_name", "content_type"
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
for field_name in required_indexes:
|
|
153
|
+
try:
|
|
154
|
+
self.client.create_payload_index(
|
|
155
|
+
collection_name=collection_name,
|
|
156
|
+
field_name=field_name,
|
|
157
|
+
field_schema=models.PayloadSchemaType.KEYWORD,
|
|
158
|
+
)
|
|
159
|
+
logger.debug(f"Created index for '{field_name}'")
|
|
160
|
+
except UnexpectedResponse as e:
|
|
161
|
+
# Index might already exist - that's fine
|
|
162
|
+
if "already exists" not in str(e).lower():
|
|
163
|
+
logger.warning(f"Could not create index for '{field_name}': {e}")
|
|
164
|
+
|
|
137
165
|
def upsert_points(self, points: list[models.PointStruct]) -> bool:
|
|
138
166
|
"""
|
|
139
167
|
Upsert points to the collection.
|
|
@@ -192,6 +220,48 @@ class QdrantSessionClient:
|
|
|
192
220
|
logger.error(f"Failed to delete session {session_id}: {e}")
|
|
193
221
|
raise
|
|
194
222
|
|
|
223
|
+
def get_session_points(self, session_id: str, user_name: str) -> list:
|
|
224
|
+
"""
|
|
225
|
+
Get all points for a session owned by this user (for write tracker seeding).
|
|
226
|
+
|
|
227
|
+
IMPORTANT: Filters by BOTH session_id AND user_name to ensure we only
|
|
228
|
+
see our own data. This is for write-side tracking only - not for retrieval.
|
|
229
|
+
|
|
230
|
+
Args:
|
|
231
|
+
session_id: Session UUID
|
|
232
|
+
user_name: User name to filter by
|
|
233
|
+
|
|
234
|
+
Returns:
|
|
235
|
+
List of Qdrant points with payloads (no vectors)
|
|
236
|
+
"""
|
|
237
|
+
points = []
|
|
238
|
+
offset = None
|
|
239
|
+
while True:
|
|
240
|
+
result = self.client.scroll(
|
|
241
|
+
collection_name=self.config.collection_name,
|
|
242
|
+
scroll_filter=models.Filter(
|
|
243
|
+
must=[
|
|
244
|
+
models.FieldCondition(
|
|
245
|
+
key="session_id",
|
|
246
|
+
match=models.MatchValue(value=session_id)
|
|
247
|
+
),
|
|
248
|
+
models.FieldCondition(
|
|
249
|
+
key="user_name",
|
|
250
|
+
match=models.MatchValue(value=user_name)
|
|
251
|
+
)
|
|
252
|
+
]
|
|
253
|
+
),
|
|
254
|
+
limit=100,
|
|
255
|
+
offset=offset,
|
|
256
|
+
with_payload=True,
|
|
257
|
+
with_vectors=False, # Don't need vectors, just metadata
|
|
258
|
+
)
|
|
259
|
+
points.extend(result[0])
|
|
260
|
+
offset = result[1]
|
|
261
|
+
if offset is None:
|
|
262
|
+
break
|
|
263
|
+
return points
|
|
264
|
+
|
|
195
265
|
def delete_by_user(self, user_name: str) -> int:
|
|
196
266
|
"""
|
|
197
267
|
Delete all points for a specific user.
|
|
@@ -387,28 +457,6 @@ class QdrantSessionClient:
|
|
|
387
457
|
logger.error(f"Failed to get points for session {session_id}: {e}")
|
|
388
458
|
raise
|
|
389
459
|
|
|
390
|
-
def get_point_by_id(self, point_id: str) -> Optional[models.Record]:
|
|
391
|
-
"""
|
|
392
|
-
Get a single point by ID.
|
|
393
|
-
|
|
394
|
-
Args:
|
|
395
|
-
point_id: Point ID to retrieve
|
|
396
|
-
|
|
397
|
-
Returns:
|
|
398
|
-
Record object or None if not found
|
|
399
|
-
"""
|
|
400
|
-
try:
|
|
401
|
-
results = self.client.retrieve(
|
|
402
|
-
collection_name=self.config.collection_name,
|
|
403
|
-
ids=[point_id],
|
|
404
|
-
with_payload=True,
|
|
405
|
-
with_vectors=False,
|
|
406
|
-
)
|
|
407
|
-
return results[0] if results else None
|
|
408
|
-
except UnexpectedResponse as e:
|
|
409
|
-
logger.error(f"Failed to get point {point_id}: {e}")
|
|
410
|
-
return None
|
|
411
|
-
|
|
412
460
|
def list_sessions(
|
|
413
461
|
self,
|
|
414
462
|
repo_id: Optional[str] = None,
|
|
@@ -424,10 +472,11 @@ class QdrantSessionClient:
|
|
|
424
472
|
Returns:
|
|
425
473
|
List of session metadata dicts
|
|
426
474
|
"""
|
|
475
|
+
# Filter by plan content_type - one per session, gives unique sessions
|
|
427
476
|
filter_conditions = [
|
|
428
477
|
models.FieldCondition(
|
|
429
|
-
key="
|
|
430
|
-
match=models.MatchValue(value="
|
|
478
|
+
key="content_type",
|
|
479
|
+
match=models.MatchValue(value="plan"),
|
|
431
480
|
)
|
|
432
481
|
]
|
|
433
482
|
|
|
@@ -455,9 +504,10 @@ class QdrantSessionClient:
|
|
|
455
504
|
"session_id": payload.get("session_id"),
|
|
456
505
|
"repo_name": payload.get("repo_name"),
|
|
457
506
|
"repo_path": payload.get("repo_path"),
|
|
507
|
+
"user_name": payload.get("user_name"),
|
|
458
508
|
"machine": payload.get("machine"),
|
|
459
509
|
"timestamp": payload.get("timestamp"),
|
|
460
|
-
"chunk_count": payload.get("
|
|
510
|
+
"chunk_count": payload.get("total_chunks", 0),
|
|
461
511
|
})
|
|
462
512
|
|
|
463
513
|
return sessions
|
|
@@ -160,6 +160,48 @@ Provide a structured security and architecture report:
|
|
|
160
160
|
|
|
161
161
|
---
|
|
162
162
|
|
|
163
|
+
## DOMAIN-SPECIFIC LENSES
|
|
164
|
+
|
|
165
|
+
Apply the lens groups that match the project type. Skip groups that don't apply.
|
|
166
|
+
|
|
167
|
+
### Web/API Projects
|
|
168
|
+
- Authentication on all routes, middleware applied correctly
|
|
169
|
+
- RBAC enforcement, role boundaries, multi-role edge cases
|
|
170
|
+
- Org/tenant isolation - all queries scoped, no cross-tenant leaks
|
|
171
|
+
- XSS in rendered content, CSRF protection, input sanitization
|
|
172
|
+
- SQL injection, IDOR vulnerabilities
|
|
173
|
+
|
|
174
|
+
### CLI Tools
|
|
175
|
+
- Argument validation and helpful error messages for bad input
|
|
176
|
+
- Exit codes (0 = success, non-zero = error, distinct codes for distinct failures)
|
|
177
|
+
- stderr for errors/diagnostics, stdout for actual output (pipeable)
|
|
178
|
+
- Signal handling (Ctrl+C graceful shutdown)
|
|
179
|
+
- Config file safety (don't corrupt on partial write, handle missing gracefully)
|
|
180
|
+
- Path handling (relative vs absolute, cross-platform if applicable)
|
|
181
|
+
|
|
182
|
+
### Data Pipelines
|
|
183
|
+
- Data integrity (checksums, validation at boundaries, corrupt input handling)
|
|
184
|
+
- Idempotency (can you safely re-run without duplication?)
|
|
185
|
+
- Error recovery (what happens when step 3 of 5 fails? Can you resume?)
|
|
186
|
+
- Backpressure (what if upstream produces faster than downstream consumes?)
|
|
187
|
+
- Schema evolution (what happens when input format changes?)
|
|
188
|
+
|
|
189
|
+
### Libraries/Packages
|
|
190
|
+
- API surface area (is the public API minimal and clear?)
|
|
191
|
+
- Backwards compatibility (will this break existing users?)
|
|
192
|
+
- Dependency weight (are you pulling in heavy deps for small features?)
|
|
193
|
+
- Documentation (are public functions/classes documented?)
|
|
194
|
+
- Version constraints (are dependency ranges appropriate?)
|
|
195
|
+
|
|
196
|
+
### Infrastructure/DevOps
|
|
197
|
+
- Secrets management (no hardcoded secrets, rotation plan)
|
|
198
|
+
- Blast radius (what's the worst case if this fails?)
|
|
199
|
+
- Rollback plan (can you undo this deployment?)
|
|
200
|
+
- Monitoring gaps (will you know if this breaks in prod?)
|
|
201
|
+
- Resource limits (memory, CPU, disk - are they bounded?)
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
163
205
|
## GENERAL PRINCIPLES
|
|
164
206
|
|
|
165
207
|
- **Be Constructive but Uncompromising**: Your job is to catch problems, but frame feedback helpfully
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Audit your CLAUDE.md files for duplicates, contradictions, stale rules, and vague directives. Companion to /learn."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are the CLAUDE.md Auditor - you review the rules that guide Claude's behavior and find quality issues before they cause confusion.
|
|
6
|
+
|
|
7
|
+
## SCOPE
|
|
8
|
+
|
|
9
|
+
Read BOTH of these files (if they exist):
|
|
10
|
+
1. **Project-level**: `CLAUDE.md` in the project root
|
|
11
|
+
2. **Global**: `~/.claude/CLAUDE.md`
|
|
12
|
+
|
|
13
|
+
If neither exists, say so and suggest using `/learn` to start building rules.
|
|
14
|
+
|
|
15
|
+
## PROCESS
|
|
16
|
+
|
|
17
|
+
### Step 1: Parse Rules
|
|
18
|
+
|
|
19
|
+
Read each file. Extract individual rules/directives (typically bullet points or lines starting with `-`). For each rule, note:
|
|
20
|
+
- The exact text
|
|
21
|
+
- Which file it's in (project vs global)
|
|
22
|
+
- Line number
|
|
23
|
+
|
|
24
|
+
### Step 2: Check for Issues
|
|
25
|
+
|
|
26
|
+
Run through these checks:
|
|
27
|
+
|
|
28
|
+
**Duplicates** - Rules that say the same thing differently:
|
|
29
|
+
- Compare rules for semantic overlap (not just exact text match)
|
|
30
|
+
- Example: "always use absolute paths" and "never use relative paths when editing" = duplicate
|
|
31
|
+
- Suggest: merge into one clear rule, delete the other
|
|
32
|
+
|
|
33
|
+
**Contradictions** - Rules that conflict:
|
|
34
|
+
- Look for ALWAYS/NEVER pairs that oppose each other
|
|
35
|
+
- Look for rules that give incompatible instructions for the same topic
|
|
36
|
+
- Example: "use tabs for indentation" vs "use 4 spaces for indentation"
|
|
37
|
+
- Suggest: resolve the contradiction, keep one
|
|
38
|
+
|
|
39
|
+
**Vague rules** - Rules that aren't actionable:
|
|
40
|
+
- No concrete action (missing ALWAYS/NEVER/WHEN)
|
|
41
|
+
- Too broad to follow ("write good code", "be careful with paths")
|
|
42
|
+
- Missing context for WHY
|
|
43
|
+
- Suggest: rewrite with specific, actionable language
|
|
44
|
+
|
|
45
|
+
**Stale rules** - Rules referencing things that may not exist:
|
|
46
|
+
- Check if referenced files/paths exist in the project (use Glob)
|
|
47
|
+
- Check if referenced tools/commands/libraries are still in use
|
|
48
|
+
- Rules about deprecated patterns or removed features
|
|
49
|
+
- Suggest: verify and remove if no longer applicable
|
|
50
|
+
|
|
51
|
+
**Scope conflicts** - Cross-file issues:
|
|
52
|
+
- Project rule duplicates a global rule (unnecessary)
|
|
53
|
+
- Project rule contradicts a global rule (confusing - which wins?)
|
|
54
|
+
- Rule in global that should be project-specific
|
|
55
|
+
- Suggest: move to appropriate scope or reconcile
|
|
56
|
+
|
|
57
|
+
### Step 3: Report
|
|
58
|
+
|
|
59
|
+
Output a structured report:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
## CLAUDE.md Audit Report
|
|
63
|
+
|
|
64
|
+
### Duplicates (X found)
|
|
65
|
+
- **Rule A** (project:L12): "always use absolute paths for Edit tool"
|
|
66
|
+
**Rule B** (global:L8): "use full system paths, not relative paths"
|
|
67
|
+
→ Suggest: Keep one, delete the other
|
|
68
|
+
|
|
69
|
+
### Contradictions (X found)
|
|
70
|
+
- **Rule A** (project:L5): "use / slashes in paths"
|
|
71
|
+
**Rule B** (global:L15): "use \ slashes in system paths"
|
|
72
|
+
→ Suggest: Clarify when each applies (or pick one)
|
|
73
|
+
|
|
74
|
+
### Vague Rules (X found)
|
|
75
|
+
- (global:L22): "try to write clean code"
|
|
76
|
+
→ Suggest: Too vague to be actionable. Rewrite or remove.
|
|
77
|
+
|
|
78
|
+
### Stale Rules (X found)
|
|
79
|
+
- (project:L8): "always run mypy before committing"
|
|
80
|
+
→ mypy not found in project dependencies. Remove if no longer used.
|
|
81
|
+
|
|
82
|
+
### Scope Conflicts (X found)
|
|
83
|
+
- (project:L3) duplicates (global:L7) - same rule in both files
|
|
84
|
+
→ Suggest: Remove from project CLAUDE.md (global already covers it)
|
|
85
|
+
|
|
86
|
+
### Summary
|
|
87
|
+
- Total rules: X (project: Y, global: Z)
|
|
88
|
+
- Issues found: N
|
|
89
|
+
- Health: CLEAN / NEEDS CLEANUP / OVERDUE FOR CONSOLIDATION
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
If 50+ total rules across both files, add:
|
|
93
|
+
"You have 50+ rules. Consider a consolidation pass - group related rules, merge duplicates, and prune what's no longer relevant."
|
|
94
|
+
|
|
95
|
+
If no issues found:
|
|
96
|
+
"Your CLAUDE.md is tight. No duplicates, contradictions, or stale rules found."
|
|
97
|
+
|
|
98
|
+
## SAFETY RAILS
|
|
99
|
+
|
|
100
|
+
- **READ-ONLY** - NEVER modify either CLAUDE.md file. Only report findings.
|
|
101
|
+
- Show suggested rewrites but tell the user to apply changes via manual editing. Note: `/learn` is append-only and cannot merge or delete existing rules, so fixing duplicates/contradictions requires direct file editing.
|
|
102
|
+
- Don't invent problems. If the rules are clean, say so. Don't pad the report.
|
|
103
|
+
- Be concrete - quote the actual rule text, not vague descriptions.
|
jacked/data/commands/dc.md
CHANGED
|
@@ -15,6 +15,13 @@ When invoked, you must:
|
|
|
15
15
|
|
|
16
16
|
Analyze these signals to determine phase:
|
|
17
17
|
|
|
18
|
+
**GRILL MODE indicators:**
|
|
19
|
+
Check BOTH `$ARGUMENTS` AND conversation history for these signals:
|
|
20
|
+
User said or typed "grill me", "grill", "challenge me", "prove this works", "poke holes", "stress test this", "be adversarial"
|
|
21
|
+
User wants to be questioned, not given a report
|
|
22
|
+
This is interactive - NOT a static review
|
|
23
|
+
Example: `/dc grill` or `/dc challenge me` should trigger grill mode
|
|
24
|
+
|
|
18
25
|
**PLANNING PHASE indicators:**
|
|
19
26
|
Recent discussion of architecture, design, or approach
|
|
20
27
|
Plan documents or markdown files recently created/edited
|
|
@@ -36,6 +43,9 @@ Commit messages or PR preparation
|
|
|
36
43
|
Code changes appear complete and coherent
|
|
37
44
|
User asking for final verification
|
|
38
45
|
|
|
46
|
+
**AMBIGUOUS/UNCLEAR indicators:**
|
|
47
|
+
If conversation has signals from multiple phases or no clear signals at all, do NOT guess. Ask the user: "I can't tell what phase you're in. What would you like me to review?" and offer the options (planning, implementation, post-implementation, grill mode).
|
|
48
|
+
|
|
39
49
|
## SPAWNING INSTRUCTIONS
|
|
40
50
|
|
|
41
51
|
Once you detect the phase, use the Task tool to spawn double-check-reviewer with these specific instructions:
|
|
@@ -43,7 +53,7 @@ Once you detect the phase, use the Task tool to spawn double-check-reviewer with
|
|
|
43
53
|
### FOR PLANNING PHASE:
|
|
44
54
|
Review this plan with ultrathink depth. Ralph Wiggum style - appear simple but catch everything.
|
|
45
55
|
|
|
46
|
-
Review lenses (RANDOMIZE ORDER, skip
|
|
56
|
+
Review lenses (RANDOMIZE ORDER, skip lenses that don't apply to this type of project):
|
|
47
57
|
- Security: Auth bypass, privilege escalation, injection, data exposure
|
|
48
58
|
- RBAC: Role boundaries enforced? Multi-role edge cases? Permission checks on all paths?
|
|
49
59
|
- Org isolation: Cross-tenant data leakage? Queries always scoped to org?
|
|
@@ -57,7 +67,7 @@ STOP CONDITION: ALL applicable lenses must pass clean. If ANY fix is made, reset
|
|
|
57
67
|
### FOR IMPLEMENTATION PHASE:
|
|
58
68
|
Review recent code changes with ultrathink depth. Ralph Wiggum style - innocent questions that expose real issues.
|
|
59
69
|
|
|
60
|
-
Review lenses (RANDOMIZE ORDER, skip
|
|
70
|
+
Review lenses (RANDOMIZE ORDER, skip lenses that don't apply to this type of project):
|
|
61
71
|
- Attacker mindset: Auth bypass? Privilege escalation? Injection? IDOR?
|
|
62
72
|
- RBAC audit: Every endpoint checks permissions? Multi-role users handled?
|
|
63
73
|
- Org isolation: All queries scoped? No cross-tenant leakage possible?
|
|
@@ -81,7 +91,7 @@ Checklist (ALL must pass):
|
|
|
81
91
|
[ ] No perf regressions
|
|
82
92
|
[ ] Tests added/updated
|
|
83
93
|
|
|
84
|
-
Review lenses (RANDOMIZE ORDER, skip
|
|
94
|
+
Review lenses (RANDOMIZE ORDER, skip lenses that don't apply to this type of project):
|
|
85
95
|
- Requirements traceability: Does code match every requirement?
|
|
86
96
|
- Defensive review: What assumptions might be wrong?
|
|
87
97
|
- Fresh eyes: What would confuse someone seeing this first time?
|
|
@@ -91,6 +101,29 @@ Review lenses (RANDOMIZE ORDER, skip N/A):
|
|
|
91
101
|
|
|
92
102
|
STOP CONDITION: Checklist 100% AND all lenses pass. Any fix resets tracker.
|
|
93
103
|
|
|
104
|
+
### FOR GRILL MODE:
|
|
105
|
+
Do NOT spawn a subagent. Handle this directly as an interactive session.
|
|
106
|
+
|
|
107
|
+
Become an adversarial interviewer. Think Socratic method meets senior engineer code review. Your goal is to stress-test the user's understanding and the design/implementation's robustness.
|
|
108
|
+
|
|
109
|
+
Rules:
|
|
110
|
+
- Ask ONE pointed question at a time. Wait for the answer.
|
|
111
|
+
- Challenge weak answers. "That sounds reasonable" is not good enough - push for specifics.
|
|
112
|
+
- Don't move on until you're satisfied or the user explicitly says to skip.
|
|
113
|
+
- Cover these angles (pick the ones that apply):
|
|
114
|
+
- "What happens when X fails?" (failure modes)
|
|
115
|
+
- "How does this handle Y at scale?" (performance/load)
|
|
116
|
+
- "Walk me through the auth flow for Z" (security)
|
|
117
|
+
- "What if a user does A instead of B?" (edge cases)
|
|
118
|
+
- "Why this approach over [alternative]?" (design justification)
|
|
119
|
+
- "What's your rollback plan if this breaks?" (operational readiness)
|
|
120
|
+
- After 5-8 questions (or when the user has survived), give a verdict:
|
|
121
|
+
- SOLID: "You've thought this through. Ship it."
|
|
122
|
+
- GAPS: "Here's what I'd tighten up before shipping: [list]"
|
|
123
|
+
- CONCERNING: "I'd rethink [specific area] before this goes out."
|
|
124
|
+
|
|
125
|
+
Skip lenses/angles that don't apply to this type of project.
|
|
126
|
+
|
|
94
127
|
## MULTI-THREAD SPAWNING
|
|
95
128
|
|
|
96
129
|
Spawn MULTIPLE parallel double-check-reviewer instances when:
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Distill a lesson from this conversation into a CLAUDE.md rule. Use after corrections, mistakes, or when you want to codify a preference."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are the Learn command - you extract lessons from the current conversation and turn them into durable CLAUDE.md rules that prevent the same mistake twice.
|
|
6
|
+
|
|
7
|
+
## INPUT HANDLING
|
|
8
|
+
|
|
9
|
+
**If `$ARGUMENTS` is provided**: Use that as the explicit lesson to encode.
|
|
10
|
+
**If no arguments**: Analyze the conversation for corrections, mistakes, user frustrations, or repeated instructions. If you genuinely cannot find a clear lesson, say so honestly. Do NOT invent a lesson just to have output.
|
|
11
|
+
|
|
12
|
+
## PROCESS
|
|
13
|
+
|
|
14
|
+
### Step 1: Identify the Lesson
|
|
15
|
+
|
|
16
|
+
Look for these signals in the conversation:
|
|
17
|
+
- User corrected Claude's approach ("no, do it THIS way")
|
|
18
|
+
- User repeated an instruction Claude forgot
|
|
19
|
+
- Claude made a wrong assumption
|
|
20
|
+
- User expressed frustration with a pattern
|
|
21
|
+
- A bug was caused by a recurring mistake
|
|
22
|
+
- User stated a preference explicitly
|
|
23
|
+
|
|
24
|
+
Extract the core lesson. Ask: "What's the GENERAL principle here, not just this specific case?"
|
|
25
|
+
|
|
26
|
+
### Step 2: Read Existing Rules AND Lessons
|
|
27
|
+
|
|
28
|
+
Check THREE places for existing coverage:
|
|
29
|
+
1. **`lessons.md`** in the project root - the auto-maintained scratchpad of session learnings
|
|
30
|
+
2. **Project-level CLAUDE.md** in the project root - permanent project rules
|
|
31
|
+
3. **`~/.claude/CLAUDE.md`** (global) - permanent global rules
|
|
32
|
+
|
|
33
|
+
For each, scan for:
|
|
34
|
+
- Rules/lessons that already cover this topic (don't duplicate)
|
|
35
|
+
- Rules that CONFLICT with the proposed lesson (flag these)
|
|
36
|
+
- The current number of rules (if 50+ in CLAUDE.md, note this)
|
|
37
|
+
|
|
38
|
+
**Graduation path**: If the lesson already exists in `lessons.md`, this is a graduation - the lesson has proven itself and the user wants it permanent. Note this in your output: "This lesson is graduating from lessons.md to a permanent CLAUDE.md rule."
|
|
39
|
+
|
|
40
|
+
### Step 3: Draft the Rule
|
|
41
|
+
|
|
42
|
+
Write a concise rule following these principles:
|
|
43
|
+
- **1-3 lines maximum** - if it takes a paragraph, it's too vague
|
|
44
|
+
- **Lead with ALWAYS or NEVER** when possible - directives, not suggestions
|
|
45
|
+
- **Lead with WHY** - the reason makes the rule stick
|
|
46
|
+
- **Be concrete** - "ALWAYS use pydantic v2 for model definitions" not "use modern libraries"
|
|
47
|
+
- **Be actionable** - Claude should know exactly what to do differently
|
|
48
|
+
|
|
49
|
+
Good examples:
|
|
50
|
+
```
|
|
51
|
+
- ALWAYS use absolute paths when calling Edit tool (relative paths cause bugs on Windows)
|
|
52
|
+
- NEVER commit .env files - use .env.example with placeholder values instead
|
|
53
|
+
- when creating pydantic models, ALWAYS use pydantic v2 field validators (v1 @validator is deprecated)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Bad examples:
|
|
57
|
+
```
|
|
58
|
+
- try to write better code (too vague)
|
|
59
|
+
- remember to be careful with paths (not actionable)
|
|
60
|
+
- there was a bug with the thing (not a rule)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Step 4: Show the User BEFORE Writing
|
|
64
|
+
|
|
65
|
+
**This is mandatory. NEVER write to CLAUDE.md without showing the user first.**
|
|
66
|
+
|
|
67
|
+
Present:
|
|
68
|
+
1. **Proposed rule**: The exact text that would be appended
|
|
69
|
+
2. **Existing related rules**: Any rules that overlap or conflict (quote them)
|
|
70
|
+
3. **Target file**: Which CLAUDE.md file (project-level by default)
|
|
71
|
+
|
|
72
|
+
Ask: "Should I add this rule to your project CLAUDE.md?"
|
|
73
|
+
|
|
74
|
+
If the user wants it in the global `~/.claude/CLAUDE.md` instead, that's fine - but default to project-level (less blast radius).
|
|
75
|
+
|
|
76
|
+
### Step 5: Write on Confirmation
|
|
77
|
+
|
|
78
|
+
- **APPEND-ONLY**: Add the rule to the end of the file. Never edit or remove existing rules.
|
|
79
|
+
- If CLAUDE.md doesn't exist, create it with a header comment.
|
|
80
|
+
- If you spotted conflicting rules in Step 2, remind the user they may want to reconcile them.
|
|
81
|
+
- If the file has 50+ rules, suggest: "Your CLAUDE.md is getting long. Consider running a consolidation pass to merge overlapping rules."
|
|
82
|
+
|
|
83
|
+
## SAFETY RAILS
|
|
84
|
+
|
|
85
|
+
- NEVER silently edit existing rules
|
|
86
|
+
- NEVER write without explicit user confirmation
|
|
87
|
+
- NEVER invent lessons from nothing - if the conversation has no clear lesson, say so
|
|
88
|
+
- ALWAYS default to project-level CLAUDE.md
|
|
89
|
+
- ALWAYS show conflicts before writing
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Scrap the current approach and re-implement from scratch with full hindsight. Creates a safety branch, stashes your work, and forces structured reflection before rewriting."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are the Redo command - you force a clean-slate re-implementation when the current approach has gone sideways. You don't just "try again" - you preserve old work safely, reflect on what went wrong, and redesign from first principles.
|
|
6
|
+
|
|
7
|
+
## PREREQUISITE CHECK
|
|
8
|
+
|
|
9
|
+
Before anything else:
|
|
10
|
+
1. **Verify you're in a git repository.** Run `git status`. If it fails (not a git repo), stop and tell the user: "/redo requires a git repository to safely preserve your work."
|
|
11
|
+
2. **Verify there IS something to redo.** Check git status and recent conversation for implementation work. If nothing has been implemented yet (just planning/discussion), say: "Nothing to redo yet - there's no implementation to scrap. Try entering plan mode to design your approach first."
|
|
12
|
+
3. If the user provides `$ARGUMENTS`, treat that as context for WHAT to redo
|
|
13
|
+
|
|
14
|
+
## PROCESS
|
|
15
|
+
|
|
16
|
+
### Step 1: Preserve Current Work
|
|
17
|
+
|
|
18
|
+
**This is non-negotiable. NEVER destroy work without saving it first.**
|
|
19
|
+
|
|
20
|
+
1. Run `git status` to check for uncommitted changes.
|
|
21
|
+
2. If there are uncommitted changes, stash them:
|
|
22
|
+
- Run `git stash push -m "redo: stashed work before re-implementation"`
|
|
23
|
+
- If the stash succeeds, tell the user: "Your current work is stashed. Run `git stash pop` if you want it back."
|
|
24
|
+
- If the stash command fails (exit code non-zero), **STOP** and tell the user the stash failed - do not proceed without preserving their work.
|
|
25
|
+
- If there's nothing to stash (clean working tree), that's fine - proceed. Already-committed work is safe in git history.
|
|
26
|
+
|
|
27
|
+
### Step 2: Create a Redo Branch
|
|
28
|
+
|
|
29
|
+
Create a new branch for the clean re-implementation. Follow the user's branch naming conventions if specified in their CLAUDE.md (e.g., naming patterns, date formats). If no convention is specified, use a descriptive name like `redo-<feature>`.
|
|
30
|
+
|
|
31
|
+
This gives you a clean canvas while keeping the old approach accessible.
|
|
32
|
+
|
|
33
|
+
### Step 3: Structured Reflection (MANDATORY)
|
|
34
|
+
|
|
35
|
+
**You MUST complete this reflection BEFORE writing any new code.** No skipping, no shortcuts.
|
|
36
|
+
|
|
37
|
+
Answer these four questions explicitly:
|
|
38
|
+
|
|
39
|
+
1. **What was the original goal?**
|
|
40
|
+
- Strip away implementation details. What were we actually trying to achieve?
|
|
41
|
+
|
|
42
|
+
2. **What went wrong with the previous approach?**
|
|
43
|
+
- Be specific. "It got messy" is not an answer.
|
|
44
|
+
- What decisions led to the mess? What assumptions were wrong?
|
|
45
|
+
|
|
46
|
+
3. **What do we know now that we didn't know before?**
|
|
47
|
+
- Constraints discovered during implementation
|
|
48
|
+
- Edge cases that weren't obvious upfront
|
|
49
|
+
- API behaviors, library limitations, data quirks
|
|
50
|
+
|
|
51
|
+
4. **What should the new approach account for?**
|
|
52
|
+
- List the gotchas and constraints from questions 2 and 3
|
|
53
|
+
- These become requirements for the redesign
|
|
54
|
+
|
|
55
|
+
Present this reflection to the user. They need to see it and confirm it captures the situation.
|
|
56
|
+
|
|
57
|
+
### Step 4: Redesign
|
|
58
|
+
|
|
59
|
+
Enter plan mode. Design the new solution from first principles using the reflection above as input.
|
|
60
|
+
|
|
61
|
+
Key mindset shifts for the redesign:
|
|
62
|
+
- **Simplest thing that works** - fight the urge to over-engineer
|
|
63
|
+
- **Address the actual failure points** - don't just rearrange the same bad approach
|
|
64
|
+
- **Use the hindsight** - you have information the first attempt didn't have
|
|
65
|
+
- **Consider if the goal itself needs adjusting** - sometimes the right redo is changing WHAT, not HOW
|
|
66
|
+
|
|
67
|
+
### Step 5: Implement
|
|
68
|
+
|
|
69
|
+
Only after the plan is approved, implement the new solution on the redo branch.
|
|
70
|
+
|
|
71
|
+
### Step 6: Wrap Up
|
|
72
|
+
|
|
73
|
+
Tell the user:
|
|
74
|
+
- Their old work is in `git stash` (if it was stashed)
|
|
75
|
+
- They're on a new branch
|
|
76
|
+
- They can compare approaches with `git diff main..HEAD` (or whatever the base branch is)
|
|
77
|
+
- If the redo is better, they can merge it. If not, they can switch back.
|
|
78
|
+
|
|
79
|
+
## SAFETY RAILS
|
|
80
|
+
|
|
81
|
+
- ALWAYS stash/preserve before doing anything destructive
|
|
82
|
+
- ALWAYS create a new branch - never redo on the same branch
|
|
83
|
+
- ALWAYS complete the reflection before writing code
|
|
84
|
+
- NEVER skip the reflection step even if the user says "just redo it"
|
|
85
|
+
- If `git stash` fails for some reason, STOP and tell the user - don't proceed without preserving their work
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: "Run a tech debt audit on your project. Finds TODOs, oversized files, missing tests, linter issues, and dead code. Pass a path to focus on a specific area."
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
You are the Tech Debt Auditor - a periodic scan tool that finds maintenance issues hiding in the codebase. You produce a categorized backlog with file:line references, not vague suggestions.
|
|
6
|
+
|
|
7
|
+
## SCOPE
|
|
8
|
+
|
|
9
|
+
**If `$ARGUMENTS` is provided**: Focus the scan on that path/area only.
|
|
10
|
+
**If no arguments**: Scan from the project root, but cap output at ~20 findings. For large codebases, tell the user to run `/techdebt <specific-area>` for deeper scans.
|
|
11
|
+
|
|
12
|
+
## PROCESS
|
|
13
|
+
|
|
14
|
+
### Step 1: Understand the Project
|
|
15
|
+
|
|
16
|
+
- Read the project structure (ls/Glob the root)
|
|
17
|
+
- Read CLAUDE.md and any config files (pyproject.toml, package.json, etc.) for context
|
|
18
|
+
- Determine the primary language(s) and tooling
|
|
19
|
+
|
|
20
|
+
### Step 2: Run Real Linters (if available)
|
|
21
|
+
|
|
22
|
+
Shell out to actual tools first. These give reliable, real findings:
|
|
23
|
+
|
|
24
|
+
**Python projects** (check for ruff/pyproject.toml):
|
|
25
|
+
```bash
|
|
26
|
+
ruff check . --statistics 2>/dev/null
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**JS/TS projects** (check for eslint config):
|
|
30
|
+
```bash
|
|
31
|
+
npx eslint . --format compact 2>/dev/null
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
If these tools aren't configured, skip them - don't install them.
|
|
35
|
+
|
|
36
|
+
### Step 3: Scan for Things Linters Miss
|
|
37
|
+
|
|
38
|
+
Use Grep and Glob to find structural debt:
|
|
39
|
+
|
|
40
|
+
1. **TODO/FIXME/HACK/XXX comments**
|
|
41
|
+
- Grep for `TODO|FIXME|HACK|XXX` patterns
|
|
42
|
+
- Include the comment text and file:line
|
|
43
|
+
|
|
44
|
+
2. **Oversized files** (500+ lines)
|
|
45
|
+
- Glob for source files, check line counts
|
|
46
|
+
- Flag anything over 500 lines
|
|
47
|
+
|
|
48
|
+
3. **Commented-out code blocks**
|
|
49
|
+
- Grep for patterns like `# def `, `# class `, `// function`, `/* `, multi-line comment blocks containing code
|
|
50
|
+
- Focus on blocks (3+ consecutive commented lines), not individual comment lines
|
|
51
|
+
|
|
52
|
+
4. **Missing test coverage**
|
|
53
|
+
- Glob for source files, compare against test files
|
|
54
|
+
- Flag source files with no corresponding test file
|
|
55
|
+
- Don't flag config files, __init__.py, etc.
|
|
56
|
+
|
|
57
|
+
5. **Stale imports** (best-effort)
|
|
58
|
+
- For Python: Grep for `import` statements, check if imported names are used elsewhere in the file
|
|
59
|
+
- Don't chase this too hard - real linters do it better
|
|
60
|
+
|
|
61
|
+
### Step 4: Categorize Findings
|
|
62
|
+
|
|
63
|
+
Group everything into three buckets:
|
|
64
|
+
|
|
65
|
+
**Bugs/Risk** - Things that could break in production:
|
|
66
|
+
- Linter errors (not warnings)
|
|
67
|
+
- TODO comments mentioning bugs or workarounds
|
|
68
|
+
- Missing error handling in critical paths
|
|
69
|
+
|
|
70
|
+
**Maintenance** - Things that slow development:
|
|
71
|
+
- Oversized files that need splitting
|
|
72
|
+
- Missing tests for important modules
|
|
73
|
+
- Stale/dead code that confuses readers
|
|
74
|
+
|
|
75
|
+
**Cleanup** - Nice-to-have tidying:
|
|
76
|
+
- TODO comments for enhancements
|
|
77
|
+
- Minor linter warnings
|
|
78
|
+
- Commented-out code
|
|
79
|
+
|
|
80
|
+
### Step 5: Output Report
|
|
81
|
+
|
|
82
|
+
Format as a structured report:
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
## Tech Debt Audit: [project or area]
|
|
86
|
+
|
|
87
|
+
### Bugs/Risk
|
|
88
|
+
- `file.py:42` - FIXME: race condition in concurrent writes
|
|
89
|
+
- `api.py:180` - No error handling for external API timeout
|
|
90
|
+
|
|
91
|
+
### Maintenance
|
|
92
|
+
- `cli.py` (847 lines) - Consider splitting command groups into separate modules
|
|
93
|
+
- `utils.py` - No test file found (utils has 12 functions)
|
|
94
|
+
- 8 stale TODO comments across 4 files
|
|
95
|
+
|
|
96
|
+
### Cleanup
|
|
97
|
+
- `old_handler.py:15-45` - 30 lines of commented-out code
|
|
98
|
+
- `models.py:3` - Unused import: `from typing import Optional`
|
|
99
|
+
|
|
100
|
+
### Linter Summary
|
|
101
|
+
[ruff/eslint output summary if available]
|
|
102
|
+
|
|
103
|
+
### Stats
|
|
104
|
+
- Files scanned: X
|
|
105
|
+
- Total findings: Y
|
|
106
|
+
- Suggested next: `/techdebt src/api/` for deeper API layer scan
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## PRINCIPLES
|
|
110
|
+
|
|
111
|
+
- **File:line references always** - every finding must be traceable
|
|
112
|
+
- **Don't pretend to be a static analyzer** - you're pattern-matching, not type-checking
|
|
113
|
+
- **Real tools first** - defer to ruff/eslint when available
|
|
114
|
+
- **Actionable over exhaustive** - 20 clear findings beat 200 noisy ones
|
|
115
|
+
- **No false authority** - if you're unsure about a finding, say "possible" not "definite"
|