Rules Capture Skill
Contract
Inputs:
- User statement that expresses a reusable rule, preference, standard, or correction
- Optional target scope: user, repo, project, skill, or session
Outputs:
- Captured pending rule with a redacted supporting quote, extracted rule, scope,
and status
- Recommendation for permanent storage location
Creates/Modifies:
- Pending capture appended to
.agents/memory/captured-rules.md (marked status: temporary)
- Permanent rules only after explicit confirmation
- Secret-like values are never written verbatim. Redact tokens, passwords, API
keys, cookies, and private credentials before saving or echoing a capture.
External Side Effects:
Confirmation Required:
- Before promoting a pending rule into permanent project or user rules
- Before editing shared/public skills based on the captured rule
Delegates To:
skill-capture when the rule is a reusable workflow that should become a skill
agent-config-audit when the rule may affect multiple config files
When This Skill Activates
Automatically activate when the user mentions ANY of these:
Direct Rule Expressions
- "always do X" / "never do X"
- "I prefer X" / "I don't like X"
- "don't ever X" / "stop doing X"
- "from now on X" / "going forward X"
- "that's not how we do it" / "we do it this way"
- "the rule is X" / "the standard is X"
Coding Style Expressions
- "use X pattern" / "don't use X pattern"
- "name things like X" / "format like X"
- "import from X" / "don't import from X"
- "the convention is X"
- "follow the X pattern"
Frustration Indicators (Capture these especially!)
- "why did you X" / "stop doing X"
- "I told you before" / "I already said"
- "that's wrong" / "that's not right"
- "fix this" / "change this"
- Any profanity + instruction (strong signal!)
Questions About Standards
- "what's the rule for X" / "how should I X"
- "is it X or Y" / "which way is correct"
- "what's the coding style for X"
Capture Process
When a rule/preference is detected:
1. Acknowledge Detection
I noticed you expressed a preference/rule. Let me capture this.
2. Extract Rule Details
Parse the user's statement to identify:
- Category: What area does this apply to? (coding, naming, imports, patterns, tools, communication)
- Rule Type: ALWAYS, NEVER, PREFER, AVOID
- Specific Action: What exactly should/shouldn't be done
- Context: When does this apply
- Example: Good vs bad example if mentioned
3. Document to Capture File
Append to .agents/memory/captured-rules.md (create the file if absent, with a YAML front-matter block including status: temporary):
### [YYYY-MM-DD HH:MM] - [Category]: [Short Title]
**User said (redacted):**
> "[Short supporting quote with secrets replaced by [REDACTED_SECRET]]"
**Rule extracted:**
- **Type**: [ALWAYS | NEVER | PREFER | AVOID]
- **Action**: [What to do/not do]
- **Context**: [When this applies]
- **Category**: [coding | naming | imports | patterns | tools | communication | workflow]
**Example:**
```[language]
// Good
[good example]
// Bad
[bad example]
```
Status: PENDING_REVIEW
### 4. Confirm with User
Captured this rule:
- [Brief summary of the rule]
Should I add this to the permanent rules? [Yes/No/Modify]
### 5. On Confirmation
- **Personal preferences** → append to the user's platform-level instruction file under the appropriate section
- **Shared project coding standards** → append to the applicable `AGENTS.md`
- **Scoped project overrides** → use `AGENTS.override.md` only when inherited guidance must be replaced for a subtree
- **Claude-specific behavior** → append to `CLAUDE.md`
- **Durable project facts** (architecture, deployment notes, gotchas) → add/update a file in `.agents/memory/`
- Remove the entry from `.agents/memory/captured-rules.md` (or mark it PROCESSED)
---
## Rule Categories
### Coding Rules
- Pattern preferences
- Import conventions
- Naming conventions
- File structure
- Component patterns
### Workflow Rules
- Build/test preferences
- Git workflow
- Documentation requirements
- Communication style
### Tool Rules
- CLI preferences
- IDE settings
- Terminal behavior
- Background processes
### Communication Rules
- Response style
- Verbosity preferences
- Explanation depth
- Acknowledgment patterns
---
## Storage Locations
| Rule Type | Storage Location |
|-----------|------------------|
| Personal preferences | User-level platform instruction file |
| Project coding standards | Repo-level agent instruction file |
| Durable project facts | `.agents/memory/<topic>.md` |
| Pending review | `.agents/memory/captured-rules.md` (`status: temporary`) |
---
## Redaction Rules
Before writing or displaying a captured quote:
- Replace API keys, tokens, passwords, cookies, private URLs, and credentials
with `[REDACTED_SECRET]`.
- Keep only the shortest quote needed to justify the rule. Summarize the rest.
- If the rule itself is about handling a secret, capture the policy, not the
secret value.
## Auto-Capture File Format
File: `.agents/memory/captured-rules.md`
```markdown
---
status: temporary
last_verified: YYYY-MM-DD
---
# Captured Rules - Pending Review
Rules automatically captured from conversations. Review and promote to permanent storage.
---
## Pending Rules
[Auto-captured rules appear here]
---
## Processed Rules
[Rules that have been promoted to CLAUDE.md or .agents/memory/]
```
---
## Integration with Other Skills
This skill works with:
- **docs**: For formatting captured rules properly
---
## Cleanup Command
When user says "clean up rules" or "process captured rules":
1. Read `.agents/memory/captured-rules.md`
2. Present each pending rule for review
3. User can: Approve, Modify, Delete
4. Approved rules get promoted to CLAUDE.md or `.agents/memory/` as appropriate
5. File is cleaned up
---
## Example Interaction
**User**: "stop using console.log for debugging, use the logger service"
**Agent**:
```
I noticed a new rule. Let me capture it:
Rule: Use logger service instead of console.log for debugging
Category: Coding
Type: NEVER (console.log) / ALWAYS (logger service)
Added to captured rules. Should I promote this to permanent coding rules?
```
---
## Activation Triggers
The skill activates on these regex patterns:
```regex
# Direct commands
(always|never|don't|stop|from now on|going forward)\s+.+
(prefer|like|want|need)\s+(you to|it to|this to)\s+.+
(the rule is|the standard is|the convention is)\s+.+
# Frustration signals
(why (did|do) you|stop doing|I told you|I already said)\s+.+
(that's (wrong|not right|incorrect)|fix this|change this)\s+.+
# Questions about standards
(what's the (rule|standard|convention) for|how should I|which way is)\s+.+
```
1---2name: rules-capture3description: Automatically detects and documents user preferences, coding standards, and workflow rules from conversation — capturing them to `.agents/memory/captured-rules.md` for promotion to permanent project or user rules. Triggers on: "always do X", "never do X", "from now on", "the rule is", "stop doing X", "I prefer", frustration indicators, or any correction to AI behavior.4---5
6# Rules Capture Skill
7
8## Contract
9
10Inputs:
11
12- User statement that expresses a reusable rule, preference, standard, or correction
13- Optional target scope: user, repo, project, skill, or session
14
15Outputs:
16
17- Captured pending rule with a redacted supporting quote, extracted rule, scope,
18 and status
19- Recommendation for permanent storage location
20
21Creates/Modifies:
22
23- Pending capture appended to `.agents/memory/captured-rules.md` (marked `status: temporary`)
24- Permanent rules only after explicit confirmation
25- Secret-like values are never written verbatim. Redact tokens, passwords, API
26 keys, cookies, and private credentials before saving or echoing a capture.
27
28External Side Effects:
29
30- None
31
32Confirmation Required:
33
34- Before promoting a pending rule into permanent project or user rules
35- Before editing shared/public skills based on the captured rule
36
37Delegates To:
38
39- `skill-capture` when the rule is a reusable workflow that should become a skill
40- `agent-config-audit` when the rule may affect multiple config files
41
42---
43
44## When This Skill Activates
45
46Automatically activate when the user mentions ANY of these:
47
48### Direct Rule Expressions
49
50- "always do X" / "never do X"
51- "I prefer X" / "I don't like X"
52- "don't ever X" / "stop doing X"
53- "from now on X" / "going forward X"
54- "that's not how we do it" / "we do it this way"
55- "the rule is X" / "the standard is X"
56
57### Coding Style Expressions
58
59- "use X pattern" / "don't use X pattern"
60- "name things like X" / "format like X"
61- "import from X" / "don't import from X"
62- "the convention is X"
63- "follow the X pattern"
64
65### Frustration Indicators (Capture these especially!)
66
67- "why did you X" / "stop doing X"
68- "I told you before" / "I already said"
69- "that's wrong" / "that's not right"
70- "fix this" / "change this"
71- Any profanity + instruction (strong signal!)
72
73### Questions About Standards
74
75- "what's the rule for X" / "how should I X"
76- "is it X or Y" / "which way is correct"
77- "what's the coding style for X"
78
79---
80
81## Capture Process
82
83When a rule/preference is detected:
84
85### 1. Acknowledge Detection
86
87```
88I noticed you expressed a preference/rule. Let me capture this.
89```
90
91### 2. Extract Rule Details
92
93Parse the user's statement to identify:
94
95- **Category**: What area does this apply to? (coding, naming, imports, patterns, tools, communication)
96- **Rule Type**: ALWAYS, NEVER, PREFER, AVOID
97- **Specific Action**: What exactly should/shouldn't be done
98- **Context**: When does this apply
99- **Example**: Good vs bad example if mentioned
100
101### 3. Document to Capture File
102
103Append to `.agents/memory/captured-rules.md` (create the file if absent, with a YAML front-matter block including `status: temporary`):
104
105````markdown
106### [YYYY-MM-DD HH:MM] - [Category]: [Short Title]
107
108**User said (redacted):**
109
110> "[Short supporting quote with secrets replaced by [REDACTED_SECRET]]"
111
112**Rule extracted:**
113
114- **Type**: [ALWAYS | NEVER | PREFER | AVOID]
115- **Action**: [What to do/not do]
116- **Context**: [When this applies]
117- **Category**: [coding | naming | imports | patterns | tools | communication | workflow]
118
119**Example:**
120
121```[language]
122// Good
123[good example]
124
125// Bad
126[bad example]
127```
128````
129
130**Status**: PENDING_REVIEW
131
132```
133
134### 4. Confirm with User
135```
136
137Captured this rule:
138
139- [Brief summary of the rule]
140
141Should I add this to the permanent rules? [Yes/No/Modify]
142
143````
144
145### 5. On Confirmation
146- **Personal preferences** → append to the user's platform-level instruction file under the appropriate section
147- **Shared project coding standards** → append to the applicable `AGENTS.md`
148- **Scoped project overrides** → use `AGENTS.override.md` only when inherited guidance must be replaced for a subtree
149- **Claude-specific behavior** → append to `CLAUDE.md`
150- **Durable project facts** (architecture, deployment notes, gotchas) → add/update a file in `.agents/memory/`
151- Remove the entry from `.agents/memory/captured-rules.md` (or mark it PROCESSED)
152
153---
154
155## Rule Categories
156
157### Coding Rules
158- Pattern preferences
159- Import conventions
160- Naming conventions
161- File structure
162- Component patterns
163
164### Workflow Rules
165- Build/test preferences
166- Git workflow
167- Documentation requirements
168- Communication style
169
170### Tool Rules
171- CLI preferences
172- IDE settings
173- Terminal behavior
174- Background processes
175
176### Communication Rules
177- Response style
178- Verbosity preferences
179- Explanation depth
180- Acknowledgment patterns
181
182---
183
184## Storage Locations
185
186| Rule Type | Storage Location |
187|-----------|------------------|
188| Personal preferences | User-level platform instruction file |
189| Project coding standards | Repo-level agent instruction file |
190| Durable project facts | `.agents/memory/<topic>.md` |
191| Pending review | `.agents/memory/captured-rules.md` (`status: temporary`) |
192
193---
194
195## Redaction Rules
196
197Before writing or displaying a captured quote:
198
199- Replace API keys, tokens, passwords, cookies, private URLs, and credentials
200 with `[REDACTED_SECRET]`.
201- Keep only the shortest quote needed to justify the rule. Summarize the rest.
202- If the rule itself is about handling a secret, capture the policy, not the
203 secret value.
204
205## Auto-Capture File Format
206
207File: `.agents/memory/captured-rules.md`
208
209```markdown
210---
211status: temporary
212last_verified: YYYY-MM-DD
213---
214
215# Captured Rules - Pending Review
216
217Rules automatically captured from conversations. Review and promote to permanent storage.
218
219---
220
221## Pending Rules
222
223[Auto-captured rules appear here]
224
225---
226
227## Processed Rules
228
229[Rules that have been promoted to CLAUDE.md or .agents/memory/]
230```
231
232---
233
234## Integration with Other Skills
235
236This skill works with:
237
238- **docs**: For formatting captured rules properly
239
240---
241
242## Cleanup Command
243
244When user says "clean up rules" or "process captured rules":
245
2461. Read `.agents/memory/captured-rules.md`
2472. Present each pending rule for review
2483. User can: Approve, Modify, Delete
2494. Approved rules get promoted to CLAUDE.md or `.agents/memory/` as appropriate
2505. File is cleaned up
251
252---
253
254## Example Interaction
255
256**User**: "stop using console.log for debugging, use the logger service"
257
258**Agent**:
259
260```
261I noticed a new rule. Let me capture it:
262
263Rule: Use logger service instead of console.log for debugging
264Category: Coding
265Type: NEVER (console.log) / ALWAYS (logger service)
266
267Added to captured rules. Should I promote this to permanent coding rules?
268```
269
270---
271
272## Activation Triggers
273
274The skill activates on these regex patterns:
275
276```regex
277# Direct commands
278(always|never|don't|stop|from now on|going forward)\s+.+
279(prefer|like|want|need)\s+(you to|it to|this to)\s+.+
280(the rule is|the standard is|the convention is)\s+.+
281
282# Frustration signals
283(why (did|do) you|stop doing|I told you|I already said)\s+.+
284(that's (wrong|not right|incorrect)|fix this|change this)\s+.+
285
286# Questions about standards
287(what's the (rule|standard|convention) for|how should I|which way is)\s+.+
288```