关于 rules-capture
rules-capture 是一项 Agent 技能,可将可复用的规则和偏好整理为待审核记录,并标明适用范围。它会遮蔽敏感信息,且须经确认才会转为永久规则。
主要功能
- 01识别规则、偏好与修正
- 02记录适用范围和提取规则
- 03遮蔽类似机密的值
- 04建议永久存储位置
- 05确认后才转为永久规则
适用场景
- 01记录对话中的编码约定
- 02保存待审核的用户偏好
- 03将可复用工作流转交 skill-capture
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ shipshitdev/ skills --skill rules-capture安装后在 Claude Code 中输入/rules-capture确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
plugin.jsonlicenses/LICENSENOTICE.txtreferences/correct-procedure.md详细介绍
规则捕获技能
契约
输入:
- 表达可复用规则、偏好、标准或更正的用户陈述
- 可选目标范围:用户、仓库、项目、技能或会话
输出:
- 已捕获的待定规则,包含脱敏后的支持性引述、提取出的规则、范围和状态
- 永久存储位置建议
创建/修改:
- 将待定捕获内容追加到
.agents/memory/captured-rules.md(标记为status: temporary) - 只有在明确确认后才添加永久规则
- 绝不逐字写入类似机密的值。保存或复述捕获内容前,先对令牌、密码、API 密钥、Cookie 和私密凭据进行脱敏。
外部副作用:
- 无
需要确认:
- 将待定规则提升为永久项目规则或用户规则之前
- 根据捕获的规则编辑共享/公开技能之前
委派给:
- 当规则是应转化为技能的可复用工作流时,委派给
skill-capture - 当规则可能影响多个配置文件时,委派给
agent-config-audit
此技能的触发条件
当用户提到以下任一内容时,自动激活:
直接表达规则
- “始终执行 X”/“绝不执行 X”
- “我更喜欢 X”/“我不喜欢 X”
- “永远不要执行 X”/“停止执行 X”
- “从现在起执行 X”/“今后执行 X”
- “这不是我们的做法”/“我们就是这样做的”
- “规则是 X”/“标准是 X”
编码风格表达
- “使用 X 模式”/“不要使用 X 模式”
- “按 X 的方式命名”/“按 X 的方式格式化”
- “从 X 导入”/“不要从 X 导入”
- “约定是 X”
- “遵循 X 模式”
表达不满的迹象(尤其要捕获!)
- “你为什么要执行 X”/“停止执行 X”
- “我之前告诉过你”/“我已经说过了”
- “这错了”/“这不对”
- “修复这个”/“更改这个”
- 任何带有指令的脏话(强烈信号!)
关于标准的问题
- “X 的规则是什么”/“我应该如何执行 X”
- “应该是 X 还是 Y”/“哪种方式才正确”
- “X 的编码风格是什么”
捕获流程
检测到规则/偏好时:
1. 确认已检测到
I noticed you expressed a preference/rule. Let me capture this.
2. 提取规则详情
解析用户陈述,识别:
- 类别:适用于哪个领域?(编码、命名、导入、模式、工具、沟通)
- 规则类型:始终、绝不、偏好、避免
- 具体操作:具体应该/不应该做什么
- 上下文:适用的情形
- 示例:如果有提及,给出正例与反例
3. 记录到捕获文件
追加到 .agents/memory/captured-rules.md(如果文件不存在,则创建文件并添加包含 status: temporary 的 YAML 前置内容块):
### [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]
```
状态:待审核
### 4. Confirm with User
已捕获此规则:
- [规则简要摘要]
要将此规则添加到永久规则中吗?[是/否/修改]
### 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)
---
## Escalate Before Documenting
A rule that repeats, or that an agent keeps breaking, belongs in structure, not prose. Before recording it as permanent text, check whether architecture, types, a lint that names the fix, or a behavior test can make the mistake impossible. Read [correct procedure](references/correct-procedure.md) for the ladder, the proof that each check fails on a real past mistake, and the rule-to-enforcer table. Record the rule as text only for judgment calls nothing can enforce.
---
## 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+.+
```
评论
支持 Markdown