claude-autopm 2.11.1 → 2.12.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.
- package/autopm/.claude/hooks/pre-action-agent-reminder.js +222 -0
- package/autopm/.claude/hooks/pre-commit-clear-reminder.sh +68 -0
- package/autopm/.claude/rules/agent-mandatory.md +80 -1
- package/autopm/.claude/rules/context-hygiene.md +270 -0
- package/autopm/.claude/scripts/check-clear-reminder.sh +42 -0
- package/autopm/.claude/templates/claude-templates/addons/task-workflow.md +40 -537
- package/package.json +1 -1
- package/packages/plugin-pm/commands/pm:blocked.md +4 -0
- package/packages/plugin-pm/commands/pm:context.md +4 -0
- package/packages/plugin-pm/commands/pm:epic-list.md +4 -0
- package/packages/plugin-pm/commands/pm:epic-show.md +4 -0
- package/packages/plugin-pm/commands/pm:epic-split.md +12 -1
- package/packages/plugin-pm/commands/pm:epic-status.md +4 -0
- package/packages/plugin-pm/commands/pm:help.md +4 -0
- package/packages/plugin-pm/commands/pm:in-progress.md +4 -0
- package/packages/plugin-pm/commands/pm:init.md +4 -0
- package/packages/plugin-pm/commands/pm:next.md +4 -0
- package/packages/plugin-pm/commands/pm:prd-list.md +4 -0
- package/packages/plugin-pm/commands/pm:prd-status.md +4 -0
- package/packages/plugin-pm/commands/pm:search.md +4 -0
- package/packages/plugin-pm/commands/pm:standup.md +4 -0
- package/packages/plugin-pm/commands/pm:status.md +4 -0
- package/packages/plugin-pm/commands/pm:validate.md +4 -0
- package/packages/plugin-pm/commands/pm:what-next.md +4 -0
- package/packages/plugin-pm/package.json +1 -1
- package/scripts/fix-command-instructions.js +221 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre-Action Agent Reminder Hook
|
|
5
|
+
*
|
|
6
|
+
* Reminds Claude to use specialized agents BEFORE performing tasks.
|
|
7
|
+
* This hook analyzes the user's request and suggests appropriate agents.
|
|
8
|
+
*
|
|
9
|
+
* IMPORTANT: This is a REMINDER, not a blocker. Claude can proceed,
|
|
10
|
+
* but should consider using agents for non-trivial tasks.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const patterns = {
|
|
14
|
+
// Code writing patterns
|
|
15
|
+
code: {
|
|
16
|
+
patterns: [
|
|
17
|
+
/writ(e|ing) code/i,
|
|
18
|
+
/creat(e|ing) (a |an )?(function|class|component|module|api|endpoint)/i,
|
|
19
|
+
/implement(ing)?/i,
|
|
20
|
+
/add (a |an )?(feature|functionality)/i,
|
|
21
|
+
/build (a |an )?/i,
|
|
22
|
+
/develop(ing)?/i
|
|
23
|
+
],
|
|
24
|
+
agents: [
|
|
25
|
+
'python-backend-engineer (Python)',
|
|
26
|
+
'nodejs-backend-engineer (Node.js/JavaScript)',
|
|
27
|
+
'react-frontend-engineer (React/Frontend)',
|
|
28
|
+
'bash-scripting-expert (Bash scripts)'
|
|
29
|
+
],
|
|
30
|
+
context7: [
|
|
31
|
+
'Query Context7 for framework-specific best practices',
|
|
32
|
+
'Check API patterns and conventions',
|
|
33
|
+
'Verify current library versions and syntax'
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// Testing patterns
|
|
38
|
+
testing: {
|
|
39
|
+
patterns: [
|
|
40
|
+
/test(s|ing)?/i,
|
|
41
|
+
/unit test/i,
|
|
42
|
+
/integration test/i,
|
|
43
|
+
/e2e test/i,
|
|
44
|
+
/run.*(test|spec)/i,
|
|
45
|
+
/write.*test/i
|
|
46
|
+
],
|
|
47
|
+
agents: [
|
|
48
|
+
'test-runner (Run and analyze tests)',
|
|
49
|
+
'frontend-testing-engineer (Frontend tests)',
|
|
50
|
+
'e2e-test-engineer (E2E tests)'
|
|
51
|
+
],
|
|
52
|
+
context7: [
|
|
53
|
+
'mcp://context7/jest/best-practices',
|
|
54
|
+
'mcp://context7/testing/tdd-patterns',
|
|
55
|
+
'mcp://context7/<framework>/testing'
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
// Database patterns
|
|
60
|
+
database: {
|
|
61
|
+
patterns: [
|
|
62
|
+
/database/i,
|
|
63
|
+
/schema/i,
|
|
64
|
+
/migration/i,
|
|
65
|
+
/query/i,
|
|
66
|
+
/sql/i,
|
|
67
|
+
/(postgres|mysql|mongodb|redis)/i
|
|
68
|
+
],
|
|
69
|
+
agents: [
|
|
70
|
+
'postgresql-expert (PostgreSQL)',
|
|
71
|
+
'mongodb-expert (MongoDB)',
|
|
72
|
+
'redis-expert (Redis)'
|
|
73
|
+
],
|
|
74
|
+
context7: [
|
|
75
|
+
'mcp://context7/<database>/schema-design',
|
|
76
|
+
'mcp://context7/<database>/query-optimization',
|
|
77
|
+
'mcp://context7/<database>/best-practices'
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
// DevOps patterns
|
|
82
|
+
devops: {
|
|
83
|
+
patterns: [
|
|
84
|
+
/deploy(ing|ment)?/i,
|
|
85
|
+
/docker/i,
|
|
86
|
+
/kubernetes/i,
|
|
87
|
+
/k8s/i,
|
|
88
|
+
/container/i,
|
|
89
|
+
/ci\/cd/i,
|
|
90
|
+
/pipeline/i
|
|
91
|
+
],
|
|
92
|
+
agents: [
|
|
93
|
+
'kubernetes-orchestrator (Kubernetes)',
|
|
94
|
+
'docker-containerization-expert (Docker)',
|
|
95
|
+
'terraform-infrastructure-expert (Terraform)',
|
|
96
|
+
'github-operations-specialist (GitHub Actions)'
|
|
97
|
+
],
|
|
98
|
+
context7: [
|
|
99
|
+
'mcp://context7/kubernetes/deployment-patterns',
|
|
100
|
+
'mcp://context7/docker/best-practices',
|
|
101
|
+
'mcp://context7/terraform/infrastructure-patterns'
|
|
102
|
+
]
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
// Code analysis patterns
|
|
106
|
+
analysis: {
|
|
107
|
+
patterns: [
|
|
108
|
+
/review/i,
|
|
109
|
+
/analyze/i,
|
|
110
|
+
/check.*bug/i,
|
|
111
|
+
/find.*issue/i,
|
|
112
|
+
/security/i,
|
|
113
|
+
/optimize/i
|
|
114
|
+
],
|
|
115
|
+
agents: [
|
|
116
|
+
'code-analyzer (Bug detection, logic tracing)',
|
|
117
|
+
'security-scanning-expert (Security analysis)'
|
|
118
|
+
],
|
|
119
|
+
context7: [
|
|
120
|
+
'mcp://context7/<language>/code-quality',
|
|
121
|
+
'mcp://context7/security/best-practices'
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
// Large file patterns
|
|
126
|
+
files: {
|
|
127
|
+
patterns: [
|
|
128
|
+
/log file/i,
|
|
129
|
+
/analyze.*file/i,
|
|
130
|
+
/summarize.*file/i,
|
|
131
|
+
/parse.*(log|output)/i
|
|
132
|
+
],
|
|
133
|
+
agents: [
|
|
134
|
+
'file-analyzer (File and log analysis)'
|
|
135
|
+
],
|
|
136
|
+
context7: [
|
|
137
|
+
'mcp://context7/logging/analysis-patterns'
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
function analyzeRequest(userMessage) {
|
|
143
|
+
const matches = [];
|
|
144
|
+
|
|
145
|
+
for (const [category, config] of Object.entries(patterns)) {
|
|
146
|
+
for (const pattern of config.patterns) {
|
|
147
|
+
if (pattern.test(userMessage)) {
|
|
148
|
+
matches.push({
|
|
149
|
+
category,
|
|
150
|
+
agents: config.agents,
|
|
151
|
+
context7: config.context7
|
|
152
|
+
});
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return matches;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function generateReminder(matches) {
|
|
162
|
+
if (matches.length === 0) {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
let reminder = '\n🤖 AGENT USAGE REMINDER\n';
|
|
167
|
+
reminder += '━'.repeat(80) + '\n\n';
|
|
168
|
+
|
|
169
|
+
reminder += '⚠️ This task may benefit from using specialized agents:\n\n';
|
|
170
|
+
|
|
171
|
+
for (const match of matches) {
|
|
172
|
+
reminder += `📋 ${match.category.toUpperCase()} TASK DETECTED\n\n`;
|
|
173
|
+
|
|
174
|
+
reminder += '**Recommended Agents:**\n';
|
|
175
|
+
for (const agent of match.agents) {
|
|
176
|
+
reminder += ` • ${agent}\n`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
reminder += '\n**Context7 Queries:**\n';
|
|
180
|
+
for (const query of match.context7) {
|
|
181
|
+
reminder += ` • ${query}\n`;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
reminder += '\n';
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
reminder += '📖 See: .claude/rules/agent-mandatory.md for complete guidance\n';
|
|
188
|
+
reminder += '━'.repeat(80) + '\n\n';
|
|
189
|
+
|
|
190
|
+
reminder += '💡 You can proceed directly if this is simple, but consider:\n';
|
|
191
|
+
reminder += ' 1. Using agents for better quality and consistency\n';
|
|
192
|
+
reminder += ' 2. Querying Context7 for up-to-date best practices\n';
|
|
193
|
+
reminder += ' 3. Following TDD cycle (RED-GREEN-REFACTOR)\n\n';
|
|
194
|
+
|
|
195
|
+
return reminder;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
function main() {
|
|
199
|
+
// Get user message from command line args or stdin
|
|
200
|
+
const args = process.argv.slice(2);
|
|
201
|
+
const userMessage = args.join(' ') || '';
|
|
202
|
+
|
|
203
|
+
if (!userMessage) {
|
|
204
|
+
// No message to analyze
|
|
205
|
+
process.exit(0);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const matches = analyzeRequest(userMessage);
|
|
209
|
+
const reminder = generateReminder(matches);
|
|
210
|
+
|
|
211
|
+
if (reminder) {
|
|
212
|
+
console.log(reminder);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
process.exit(0);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (require.main === module) {
|
|
219
|
+
main();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
module.exports = { analyzeRequest, generateReminder };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Pre-Commit Clear Reminder Hook
|
|
4
|
+
#
|
|
5
|
+
# Detects when an issue is being closed and reminds to run /clear
|
|
6
|
+
# before starting the next issue.
|
|
7
|
+
|
|
8
|
+
# Get the commit message
|
|
9
|
+
COMMIT_MSG_FILE="$1"
|
|
10
|
+
COMMIT_MSG=$(cat "$COMMIT_MSG_FILE" 2>/dev/null || git log --format=%B -n 1 HEAD 2>/dev/null)
|
|
11
|
+
|
|
12
|
+
# Patterns that indicate issue closure
|
|
13
|
+
CLOSING_PATTERNS=(
|
|
14
|
+
"close #"
|
|
15
|
+
"closes #"
|
|
16
|
+
"closed #"
|
|
17
|
+
"fix #"
|
|
18
|
+
"fixes #"
|
|
19
|
+
"fixed #"
|
|
20
|
+
"resolve #"
|
|
21
|
+
"resolves #"
|
|
22
|
+
"resolved #"
|
|
23
|
+
"complete #"
|
|
24
|
+
"completes #"
|
|
25
|
+
"completed #"
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
# Check if commit message contains issue closing keywords
|
|
29
|
+
issue_closed=false
|
|
30
|
+
for pattern in "${CLOSING_PATTERNS[@]}"; do
|
|
31
|
+
if echo "$COMMIT_MSG" | grep -qi "$pattern"; then
|
|
32
|
+
issue_closed=true
|
|
33
|
+
break
|
|
34
|
+
fi
|
|
35
|
+
done
|
|
36
|
+
|
|
37
|
+
# If issue is being closed, show reminder
|
|
38
|
+
if [ "$issue_closed" = true ]; then
|
|
39
|
+
echo ""
|
|
40
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
41
|
+
echo "🧹 CONTEXT HYGIENE REMINDER"
|
|
42
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
43
|
+
echo ""
|
|
44
|
+
echo "⚠️ This commit closes an issue!"
|
|
45
|
+
echo ""
|
|
46
|
+
echo "📋 IMPORTANT: After this commit, run /clear before starting"
|
|
47
|
+
echo " the next issue to prevent context bleed."
|
|
48
|
+
echo ""
|
|
49
|
+
echo "Why this matters:"
|
|
50
|
+
echo " • Prevents mixing context from different issues"
|
|
51
|
+
echo " • Ensures Claude starts fresh for each task"
|
|
52
|
+
echo " • Reduces token usage"
|
|
53
|
+
echo " • Improves response quality"
|
|
54
|
+
echo ""
|
|
55
|
+
echo "Next steps:"
|
|
56
|
+
echo " 1. ✅ Complete this commit"
|
|
57
|
+
echo " 2. 🧹 Type: /clear"
|
|
58
|
+
echo " 3. 📝 Start next issue with clean context"
|
|
59
|
+
echo ""
|
|
60
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
61
|
+
echo ""
|
|
62
|
+
|
|
63
|
+
# Optional: Create a reminder file
|
|
64
|
+
echo "REMINDER: Run /clear before next issue" > .claude/.clear-reminder
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
# Always allow commit to proceed
|
|
68
|
+
exit 0
|
|
@@ -2,12 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
**🚨 CRITICAL: This rule has HIGHEST PRIORITY and MUST be followed for ALL tasks.**
|
|
4
4
|
|
|
5
|
+
## ⚠️ BEFORE YOU START ANY TASK - READ THIS
|
|
6
|
+
|
|
7
|
+
**MANDATORY SELF-CHECK:**
|
|
8
|
+
|
|
9
|
+
Before doing ANYTHING complex, ask yourself:
|
|
10
|
+
1. ❓ Is this writing code? → **USE AGENT**
|
|
11
|
+
2. ❓ Is this testing code? → **USE test-runner**
|
|
12
|
+
3. ❓ Is this analyzing code/files? → **USE code-analyzer or file-analyzer**
|
|
13
|
+
4. ❓ Is this database work? → **USE database expert agent**
|
|
14
|
+
5. ❓ Is this DevOps/infrastructure? → **USE DevOps agent**
|
|
15
|
+
|
|
16
|
+
**If YES to ANY → STOP and USE the appropriate agent!**
|
|
17
|
+
|
|
5
18
|
## Core Requirement
|
|
6
19
|
|
|
7
20
|
**YOU MUST USE SPECIALIZED AGENTS FOR ALL NON-TRIVIAL TASKS.**
|
|
8
21
|
|
|
9
22
|
Do NOT perform complex tasks yourself. Use the Task tool to delegate to appropriate agents.
|
|
10
23
|
|
|
24
|
+
### Why This Rule Exists
|
|
25
|
+
|
|
26
|
+
1. **Quality**: Specialized agents have deeper expertise
|
|
27
|
+
2. **Consistency**: Agents follow established patterns
|
|
28
|
+
3. **Context7**: Agents query live documentation (you should too!)
|
|
29
|
+
4. **TDD**: Agents enforce RED-GREEN-REFACTOR cycle
|
|
30
|
+
5. **Best Practices**: Agents apply industry standards
|
|
31
|
+
|
|
32
|
+
### What Happens When You Don't Use Agents
|
|
33
|
+
|
|
34
|
+
❌ **Common failures:**
|
|
35
|
+
- Code without tests (violates TDD)
|
|
36
|
+
- Missing Context7 queries (outdated patterns)
|
|
37
|
+
- Inconsistent code style
|
|
38
|
+
- Security vulnerabilities
|
|
39
|
+
- Performance issues
|
|
40
|
+
- Missing error handling
|
|
41
|
+
|
|
11
42
|
## When to Use Agents
|
|
12
43
|
|
|
13
44
|
### ✅ ALWAYS Use Agents For:
|
|
@@ -160,11 +191,59 @@ If you're unsure whether to use an agent:
|
|
|
160
191
|
- When in doubt, delegate to specialist
|
|
161
192
|
- Better to over-use agents than under-use them
|
|
162
193
|
|
|
194
|
+
## Context7 Integration - ALSO MANDATORY
|
|
195
|
+
|
|
196
|
+
**In addition to using agents, you MUST query Context7 for up-to-date documentation.**
|
|
197
|
+
|
|
198
|
+
### When to Query Context7
|
|
199
|
+
|
|
200
|
+
**BEFORE implementing ANY code:**
|
|
201
|
+
```bash
|
|
202
|
+
# Query relevant documentation
|
|
203
|
+
mcp://context7/<framework>/<topic>
|
|
204
|
+
mcp://context7/<language>/best-practices
|
|
205
|
+
mcp://context7/<library>/api-reference
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Why Context7 is Required
|
|
209
|
+
|
|
210
|
+
1. **Up-to-date info**: Your training data may be outdated
|
|
211
|
+
2. **API changes**: Libraries evolve, APIs change
|
|
212
|
+
3. **Best practices**: Current industry standards
|
|
213
|
+
4. **Bug fixes**: Known issues and workarounds
|
|
214
|
+
|
|
215
|
+
### Examples
|
|
216
|
+
|
|
217
|
+
**Writing Python FastAPI code:**
|
|
218
|
+
```bash
|
|
219
|
+
# Query BEFORE implementation
|
|
220
|
+
mcp://context7/fastapi/routing
|
|
221
|
+
mcp://context7/fastapi/validation
|
|
222
|
+
mcp://context7/pydantic/models
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**Writing React components:**
|
|
226
|
+
```bash
|
|
227
|
+
# Query BEFORE implementation
|
|
228
|
+
mcp://context7/react/hooks
|
|
229
|
+
mcp://context7/react/18.0/best-practices
|
|
230
|
+
mcp://context7/typescript/react-patterns
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Database schema design:**
|
|
234
|
+
```bash
|
|
235
|
+
# Query BEFORE implementation
|
|
236
|
+
mcp://context7/postgresql/schema-design
|
|
237
|
+
mcp://context7/postgresql/indexing
|
|
238
|
+
mcp://context7/postgresql/performance
|
|
239
|
+
```
|
|
240
|
+
|
|
163
241
|
## Summary
|
|
164
242
|
|
|
165
243
|
**Before doing ANY complex task, ask yourself:**
|
|
166
244
|
1. Is there a specialized agent for this?
|
|
167
245
|
2. Would an agent do this better/faster/more thoroughly?
|
|
168
246
|
3. Am I trying to do something I should delegate?
|
|
247
|
+
4. Should I query Context7 for current best practices?
|
|
169
248
|
|
|
170
|
-
**If answer is YES to any → USE THE AGENT!**
|
|
249
|
+
**If answer is YES to any → USE THE AGENT! AND QUERY CONTEXT7!**
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
# Context Hygiene - MANDATORY
|
|
2
|
+
|
|
3
|
+
**🧹 CRITICAL: Run `/clear` between issues to prevent context bleed.**
|
|
4
|
+
|
|
5
|
+
## Core Requirement
|
|
6
|
+
|
|
7
|
+
**YOU MUST CLEAR CONTEXT AFTER COMPLETING EACH ISSUE.**
|
|
8
|
+
|
|
9
|
+
Context from previous issues can:
|
|
10
|
+
- ❌ Cause incorrect assumptions
|
|
11
|
+
- ❌ Mix concerns from different tasks
|
|
12
|
+
- ❌ Waste tokens on irrelevant history
|
|
13
|
+
- ❌ Reduce response quality
|
|
14
|
+
|
|
15
|
+
## When to Run /clear
|
|
16
|
+
|
|
17
|
+
### ✅ ALWAYS Clear After:
|
|
18
|
+
|
|
19
|
+
1. **Issue/Task Completion**
|
|
20
|
+
- After merging PR that closes an issue
|
|
21
|
+
- After marking task as complete
|
|
22
|
+
- Before starting new issue
|
|
23
|
+
|
|
24
|
+
2. **Context Switches**
|
|
25
|
+
- Switching between different features
|
|
26
|
+
- Moving to different part of codebase
|
|
27
|
+
- Changing from bug fix to feature development
|
|
28
|
+
|
|
29
|
+
3. **Long Conversations**
|
|
30
|
+
- After 20+ messages in one issue
|
|
31
|
+
- When context window getting full
|
|
32
|
+
- When conversation becomes unfocused
|
|
33
|
+
|
|
34
|
+
4. **Daily Boundaries**
|
|
35
|
+
- At end of work day
|
|
36
|
+
- At start of new work session
|
|
37
|
+
- After long breaks
|
|
38
|
+
|
|
39
|
+
### 🔴 NEVER Skip /clear When:
|
|
40
|
+
|
|
41
|
+
- Closing an issue (MOST IMPORTANT)
|
|
42
|
+
- Starting a new issue
|
|
43
|
+
- Switching work contexts
|
|
44
|
+
- After merge conflicts resolved
|
|
45
|
+
- After completing refactoring
|
|
46
|
+
|
|
47
|
+
## How to Use /clear
|
|
48
|
+
|
|
49
|
+
### Manual Trigger:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Type this in Claude Code CLI:
|
|
53
|
+
/clear
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Expected Behavior:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
Claude Code: "Context cleared. Ready for next task."
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Enforcement
|
|
63
|
+
|
|
64
|
+
### Git Hook Reminder
|
|
65
|
+
|
|
66
|
+
Pre-commit hook detects issue closure and reminds:
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
🧹 CONTEXT HYGIENE REMINDER
|
|
70
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
71
|
+
|
|
72
|
+
⚠️ This commit closes an issue!
|
|
73
|
+
|
|
74
|
+
📋 IMPORTANT: After this commit, run /clear before starting
|
|
75
|
+
the next issue to prevent context bleed.
|
|
76
|
+
|
|
77
|
+
Next steps:
|
|
78
|
+
1. ✅ Complete this commit
|
|
79
|
+
2. 🧹 Type: /clear
|
|
80
|
+
3. 📝 Start next issue with clean context
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### PM Command Integration
|
|
84
|
+
|
|
85
|
+
PM commands include `/clear` reminders:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
# After completing issue
|
|
89
|
+
/pm:issue-complete 123
|
|
90
|
+
|
|
91
|
+
# Output includes:
|
|
92
|
+
# ✅ Issue #123 marked as complete
|
|
93
|
+
# 🧹 REMINDER: Run /clear before starting next issue
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Workflow Integration
|
|
97
|
+
|
|
98
|
+
### Standard Issue Workflow:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# 1. Start issue
|
|
102
|
+
/pm:issue-start 123
|
|
103
|
+
|
|
104
|
+
# 2. Work on issue...
|
|
105
|
+
# ... implement, test, commit ...
|
|
106
|
+
|
|
107
|
+
# 3. Complete issue
|
|
108
|
+
git commit -m "fix: resolve issue #123"
|
|
109
|
+
git push
|
|
110
|
+
|
|
111
|
+
# 4. CLEAR CONTEXT (MANDATORY)
|
|
112
|
+
/clear
|
|
113
|
+
|
|
114
|
+
# 5. Start next issue with clean slate
|
|
115
|
+
/pm:issue-start 124
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Example Violation:
|
|
119
|
+
|
|
120
|
+
❌ **WRONG - No /clear:**
|
|
121
|
+
```bash
|
|
122
|
+
# Complete issue 123
|
|
123
|
+
git commit -m "fix: issue #123"
|
|
124
|
+
|
|
125
|
+
# Immediately start issue 124 (BAD!)
|
|
126
|
+
/pm:issue-start 124
|
|
127
|
+
# Context from #123 still present!
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
✅ **CORRECT - With /clear:**
|
|
131
|
+
```bash
|
|
132
|
+
# Complete issue 123
|
|
133
|
+
git commit -m "fix: issue #123"
|
|
134
|
+
|
|
135
|
+
# Clear context (REQUIRED)
|
|
136
|
+
/clear
|
|
137
|
+
|
|
138
|
+
# Now start issue 124
|
|
139
|
+
/pm:issue-start 124
|
|
140
|
+
# Fresh context, no bleed from #123
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Why This Matters
|
|
144
|
+
|
|
145
|
+
### Context Bleed Examples:
|
|
146
|
+
|
|
147
|
+
**Without /clear:**
|
|
148
|
+
```
|
|
149
|
+
Issue #123: Add user authentication
|
|
150
|
+
Claude remembers: "We're working on auth..."
|
|
151
|
+
|
|
152
|
+
Issue #124: Fix database query bug
|
|
153
|
+
Claude thinks: "This must be related to auth system from #123"
|
|
154
|
+
# WRONG ASSUMPTION - wastes time debugging wrong area
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**With /clear:**
|
|
158
|
+
```
|
|
159
|
+
Issue #123: Add user authentication
|
|
160
|
+
/clear
|
|
161
|
+
|
|
162
|
+
Issue #124: Fix database query bug
|
|
163
|
+
Claude thinks: "Fresh start, what's the actual issue?"
|
|
164
|
+
# CORRECT - focuses on actual problem
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Token Efficiency:
|
|
168
|
+
|
|
169
|
+
**Without /clear:**
|
|
170
|
+
- Context window: 50k+ tokens from previous issues
|
|
171
|
+
- Available for work: 150k tokens
|
|
172
|
+
- Efficiency: 75%
|
|
173
|
+
|
|
174
|
+
**With /clear:**
|
|
175
|
+
- Context window: 5k tokens (fresh start)
|
|
176
|
+
- Available for work: 195k tokens
|
|
177
|
+
- Efficiency: 97.5%
|
|
178
|
+
|
|
179
|
+
## Best Practices
|
|
180
|
+
|
|
181
|
+
### 1. Clear After Every PR Merge
|
|
182
|
+
|
|
183
|
+
```bash
|
|
184
|
+
# Merge PR
|
|
185
|
+
gh pr merge 123 --squash
|
|
186
|
+
|
|
187
|
+
# Immediate clear
|
|
188
|
+
/clear
|
|
189
|
+
|
|
190
|
+
# Ready for next task
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 2. Clear Before Starting New Feature
|
|
194
|
+
|
|
195
|
+
```bash
|
|
196
|
+
# Check what's next
|
|
197
|
+
/pm:backlog
|
|
198
|
+
|
|
199
|
+
# Pick issue
|
|
200
|
+
/pm:issue-start 125
|
|
201
|
+
|
|
202
|
+
# But first...
|
|
203
|
+
/clear
|
|
204
|
+
|
|
205
|
+
# Now start fresh
|
|
206
|
+
/pm:issue-start 125
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### 3. Clear After Context Gets Large
|
|
210
|
+
|
|
211
|
+
Check context size with:
|
|
212
|
+
```bash
|
|
213
|
+
# If conversation has 20+ messages
|
|
214
|
+
# Or if responses become slow
|
|
215
|
+
# Or if Claude seems confused
|
|
216
|
+
|
|
217
|
+
# CLEAR IT
|
|
218
|
+
/clear
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Automation Ideas
|
|
222
|
+
|
|
223
|
+
### Option 1: Auto-Clear on Issue Close
|
|
224
|
+
|
|
225
|
+
**PM command auto-clears:**
|
|
226
|
+
```bash
|
|
227
|
+
/pm:issue-complete 123
|
|
228
|
+
# Automatically runs /clear internally
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### Option 2: Clear Reminder File
|
|
232
|
+
|
|
233
|
+
**Hook creates reminder:**
|
|
234
|
+
```bash
|
|
235
|
+
# After commit that closes issue
|
|
236
|
+
# Creates: .claude/.clear-reminder
|
|
237
|
+
|
|
238
|
+
# Next Claude interaction checks:
|
|
239
|
+
if [ -f .claude/.clear-reminder ]; then
|
|
240
|
+
echo "⚠️ REMINDER: Run /clear before continuing"
|
|
241
|
+
fi
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Option 3: Session Start Check
|
|
245
|
+
|
|
246
|
+
**Check on session start:**
|
|
247
|
+
```bash
|
|
248
|
+
# In CLAUDE.md:
|
|
249
|
+
## Session Start Protocol
|
|
250
|
+
1. Check for .clear-reminder file
|
|
251
|
+
2. If exists, warn user
|
|
252
|
+
3. Remove file after /clear
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Summary
|
|
256
|
+
|
|
257
|
+
**Context hygiene is as important as code hygiene.**
|
|
258
|
+
|
|
259
|
+
### Remember:
|
|
260
|
+
- 🧹 **ALWAYS** `/clear` after issue completion
|
|
261
|
+
- 🧹 **ALWAYS** `/clear` before new issue
|
|
262
|
+
- 🧹 **ALWAYS** `/clear` on context switch
|
|
263
|
+
|
|
264
|
+
### Benefits:
|
|
265
|
+
- ✅ No context bleed between issues
|
|
266
|
+
- ✅ Better response quality
|
|
267
|
+
- ✅ More efficient token usage
|
|
268
|
+
- ✅ Clearer thinking for each task
|
|
269
|
+
|
|
270
|
+
**Make `/clear` a habit, not an afterthought.**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Check for /clear reminder
|
|
4
|
+
#
|
|
5
|
+
# This script checks if there's a pending /clear reminder
|
|
6
|
+
# and displays it to the user.
|
|
7
|
+
#
|
|
8
|
+
# Should be run at session start or before new commands.
|
|
9
|
+
|
|
10
|
+
REMINDER_FILE=".claude/.clear-reminder"
|
|
11
|
+
|
|
12
|
+
if [ -f "$REMINDER_FILE" ]; then
|
|
13
|
+
echo ""
|
|
14
|
+
echo "╔════════════════════════════════════════════════════════════════╗"
|
|
15
|
+
echo "║ 🧹 PENDING /clear REMINDER ║"
|
|
16
|
+
echo "╚════════════════════════════════════════════════════════════════╝"
|
|
17
|
+
echo ""
|
|
18
|
+
echo "⚠️ You have a pending context clear reminder from:"
|
|
19
|
+
echo ""
|
|
20
|
+
cat "$REMINDER_FILE"
|
|
21
|
+
echo ""
|
|
22
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
23
|
+
echo ""
|
|
24
|
+
echo "Why this is important:"
|
|
25
|
+
echo " • Prevents context bleed from previous issue"
|
|
26
|
+
echo " • Ensures fresh start for new task"
|
|
27
|
+
echo " • Improves response quality"
|
|
28
|
+
echo " • Reduces token waste"
|
|
29
|
+
echo ""
|
|
30
|
+
echo "Action required:"
|
|
31
|
+
echo " 1. Type: /clear"
|
|
32
|
+
echo " 2. This reminder will be automatically removed"
|
|
33
|
+
echo " 3. Then proceed with your new task"
|
|
34
|
+
echo ""
|
|
35
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
# Optional: Block until /clear is run
|
|
39
|
+
# Uncomment to enforce /clear before proceeding:
|
|
40
|
+
# read -p "Press Enter after running /clear to continue..."
|
|
41
|
+
# rm "$REMINDER_FILE"
|
|
42
|
+
fi
|