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