writing-rules

SKILL开发
开发 未标注权限 许可证不明确

Use when creating rule files in .claude/rules/, adding project conventions, or scoping guidelines to specific paths. Use when user says "add rule", "create convention", "scope guideline". NOT for laws (use <law> in CLAUDE.md).

一句话选型结论

按资料字段整理

writing-rules是开发类的 Agent Skill,安装方式:GitHub 仓库,权限级别未标注,许可证不明确,没有现成安装命令,需按说明手动放置 SKILL.md。技能本质是给模型读的说明书,效果取决于模型与客户端;装完先用一个小任务验证,再放进正式流程。

分类开发 安装方式GitHub 仓库 权限级别未标注权限 许可证许可证不明确
累计安装 未标注 本周 未标注
GitHub 星标 11 仓库 Reflexive-Claude-Code
下载量 未标注 技能市场下载数
权限级别 未标注权限 安装前请确认风险范围
许可证 许可证不明确 未说明

安装

GitHub 仓库
在支持 Skills 的客户端里执行,装完问一句「你有哪些技能」验证
  1. 1
    确认客户端支持

    确认你的客户端支持 Skills(Claude、Codex、Cursor 等),并升级到较新的版本。

  2. 2
    拿到技能文件

    按安装说明或仓库 README,把 SKILL.md 放到客户端的 skills 目录(一般一个技能一个文件夹)。

  3. 3
    刷新技能列表

    重新打开客户端,或刷新技能列表,让新放进来的技能被加载。

  4. 4
    验证是否生效

    问一句「你有哪些技能」,确认列表里出现它,再拿一个小任务试跑。

技能档案

开发
字段来自技能仓库与公开索引,中文说明由本站标注
作者 / 维护方wayne930242仓库 Reflexive-Claude-Code · 版本 未标注
宿主客户端未标注技能可被这些客户端加载
安装方式GitHub 仓库安装包 wayne930242/Reflexive-Claude-Code
权限级别未标注权限安装前请确认风险范围
许可证未说明许可证不明确,商用前请自行确认条款
仓库可用性available技能仓库当前是否可访问
最近核验未标注上游最后核验时间 · 数据更新 未标注
正文体量10.0 KBSKILL.md 原文大小,越大说明说明书写得越细

典型使用场景

3 类
按分类整理的常见用法,具体以 SKILL.md 为准
写代码与改 bug

按需求补代码、定位并修掉报错。

读仓库与生成改动

让模型读懂项目结构,再给出可落地的改动。

跑测试与排查故障

按现象排查问题,补测试用例并复跑。

选择建议

装之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 基础信息齐全,可以先按说明装一个试试。

先想清楚的地方

  • 没有标注权限级别,实际能做什么要装好后确认。
  • 许可证不明确,商用或二次分发前先到仓库确认条款。
  • 没有现成安装命令,要按安装说明或仓库 README 手动放置。
  • 没有做站内核验,内容以作者仓库为准。
  • 技能只是说明书,实际效果取决于模型与客户端,装完先用小任务试一遍。

更适合

  • 需要在开发场景里给模型补一套做法的人。
  • 愿意先读一遍 SKILL.md、确认它会让模型做什么的人。

不太适合

  • 对许可证要求很严、必须明确可商用的人。
  • 只想装完就自动变强、不打算看说明书的人。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
技能权限级别安装方式累计安装宿主客户端安装命令
writing-rules当前 未标注权限 GitHub 仓库 未标注 未标注 无
技能审查员 浏览器控制 ClawHub 市场 877.9 万 OpenClaw 有
Vercel React 最佳实践 浏览器控制 GitHub 仓库 849.1 万 Codex、Claude、Cursor 有
GitHub 代码协作 联网访问 ClawHub 市场 763.3 万 OpenClaw 有
网页设计指南 联网访问 GitHub 仓库 668.6 万 Codex、Claude、Cursor 有
本体论 只读 ClawHub 市场 663.7 万 OpenClaw 有

SKILL.md 全文

10.0 KB
模型实际读到的说明书原文,来自技能仓库

Writing Rules

Overview

Writing rules IS creating focused, path-scoped conventions that load only when they are relevant.

paths: is a real load gate. Per the official spec: "Rules without a paths field are loaded unconditionally and apply to all files. Path-scoped rules trigger when Claude reads files matching the pattern, not on every tool use." Rules without paths: load at launch with the same priority as .claude/CLAUDE.md; rules with paths: cost nothing until Claude touches a matching file.

Core principle: Rules = small, focused conventions, scoped with paths: so they stay out of context until needed. CLAUDE.md = top-level project identity, build commands, gotchas — always resident, so keep it under 200 lines. Hard rules that must never be bypassed = hooks (instruction compliance is ~70%, not 100%).

Task Initialization (MANDATORY)

Follow task initialization protocol.

Tasks:
0. Fetch latest official rule/skill spec
1. Analyze requirements
2. RED - test without rule
3. GREEN - write rule file
4. Validate structure
5. REFACTOR - quality review
6. Test activation

Announce: "Created 7 tasks (0–6). Starting execution..."

Configuration Creation Process

Phase Focus What You Do
Analysis Understanding Identify what convention needs enforcement
Scope Definition Targeting Determine which files need this convention
Design Planning Structure rule content and path patterns
Implementation Creation Write clear, specific configuration rules
Optimization Refinement Streamline scope and improve clarity

Task 0: Fetch Latest Official Spec

Goal: Pull the current Anthropic spec for path-scoped rules / skill frontmatter before designing — never trust cached memory.

Action:

Skill tool: fetching-claude-docs
  component: memory
  question: &quot;CLAUDE.md auto-loading behavior, .claude/rules/ directory loading,
             nested CLAUDE.md per directory, @ import syntax, token cost&quot;

Verification: Received YAML with non-empty spec_excerpt. Use as authoritative reference. If the fetched spec contradicts anything in this SKILL, the fetched spec wins — record the contradiction so this SKILL can be corrected.

Task 1: Analyze Requirements

Goal: Understand what convention to encode and where it applies.

Questions to answer, in order:
- Is it a hard rule that must never be bypassed? → Use a hook, not a rule.
- Does it require multi-step procedure? → Use a skill, not a rule.
- Does it apply to a specific file glob? → Path-scoped rule file.
- Otherwise: does CLAUDE.md + all unscoped rules stay under 200 lines with this added? → Add to CLAUDE.md. If it would push over budget → unscoped rule file, split for readability.
- Does this rule already exist? (compare against auto-loaded rule content in context — do NOT Read or Grep rule files)

Verification: Can state the convention in one sentence, name the file glob it applies to (or justify why it is genuinely cross-cutting), and confirm it isn't a hard rule (which would belong in a hook).

Task 2: RED - Test Without Rule

Goal: Work on matching files WITHOUT the rule. Note where convention is forgotten.

Process:
1. Identify 2-3 files that would match the rule
2. Ask agent to modify those files
3. Observe if conventions are followed naturally
4. Document specific violations

Verification: Documented at least 1 instance where convention was not followed.

Task 3: GREEN - Write Rule File

Goal: Create rule file addressing the gaps you documented.

Rule Location

~/.claude/rules/             # User-level (applies to every project)
.claude/rules/               # Project-level (this project only)
├── code-style.md            # Unscoped (no paths:) — loads at launch, every session
├── api/
│   └── conventions.md       # paths: [&quot;src/api/**&quot;]  ← loads only on matching files
└── testing/
    └── guidelines.md        # paths: [&quot;**/*.test.ts&quot;]

All .md files are discovered recursively, so subdirectories are just organization.

Rule Format

---
paths:                        # Omit only for genuinely cross-cutting rules
  - &quot;src/api/**/*.ts&quot;
---

# Rule Title

- Constraint 1 (imperative: &quot;MUST&quot;, &quot;NEVER&quot;)
- Constraint 2

Loading Mechanism

  • Without paths: — loaded at launch, every session, same priority as .claude/CLAUDE.md. Costs tokens in every conversation.
  • With paths: — loaded when Claude reads a file matching the glob, not on every tool use. Costs nothing until then. This is the reason to scope aggressively.
  • User-level ~/.claude/rules/ loads before project rules, giving project rules higher priority.
  • Symlinks are supported for sharing rules across projects; circular symlinks are handled.
  • For deterministic enforcement (hard-stop a tool call), use a hook — rules cannot enforce, only suggest.

Writing Rules

Key constraints:
- < 50 lines — long rules dilute adherence, and unscoped ones cost tokens every session
- Imperative form — "MUST use", not "try to use"
- No procedures — how-to belongs in skills
- Scope with paths: — this genuinely gates loading. Omit it only when the rule really applies to all work.

See references/examples.md for good/bad rule examples by domain.

Content validation checks:

Check Fail condition Action
Line count > 50 lines Must simplify or split
Procedural content Contains numbered steps, multi-line code blocks Extract to skill, rule keeps principle only
paths missing Content targets specific file types but no paths: Add it — this is free context savings, not just documentation
paths too broad paths: &quot;**/*&quot; or similar Equivalent to unscoped but lazier; either narrow it or drop paths: entirely
Hard rule Says "MUST NEVER" about destructive/irreversible action Move to hook (deterministic enforcement); a rule alone is ~70% reliable
Load budget Adding this rule pushes CLAUDE.md + all unscoped rules > 200 lines Warn, simplify, merge, or scope with paths:

Verification:
- [ ] Has paths: scoping it (or a stated reason why it is genuinely cross-cutting)
- [ ] < 50 lines
- [ ] Imperative language ("MUST", "NEVER")
- [ ] No procedural content (steps, code blocks as process)
- [ ] Hard rules (destructive ops, irreversible actions) have a backing hook — not just text
- [ ] Not duplicating existing rules or CLAUDE.md (compare against content already in context — do NOT Read or Grep rule files)
- [ ] Always-resident total (CLAUDE.md + every unscoped rule) still under 200 lines

Task 4: Validate Structure

Goal: Verify rule file structure is correct.

Checklist:
- [ ] File is under .claude/rules/ (nested subdirectories are fine — discovery is recursive)
- [ ] Frontmatter has valid paths: glob (or none, deliberately, for a cross-cutting rule)
- [ ] Body < 50 lines
- [ ] Uses imperative language
- [ ] No how-to instructions (belongs in skills)
- [ ] Not duplicating content already in CLAUDE.md

Verification: All checklist items pass.

Task 5: REFACTOR - Quality Review

Goal: Have rule reviewed by rule-reviewer subagent.

Agent tool:
- subagent_type: &quot;rcc:rule-reviewer&quot;
- prompt: &quot;Review rule at [path]&quot;

Interpret YAML output:
- pass: true → Proceed to Task 6
- pass: false → Fix all issues listed, re-run reviewer, repeat until pass: true

Verification: rule-reviewer returns YAML with pass: true.

Task 6: Test Activation

Goal: Verify rule actually activates on matching files.

Process:
1. Create/open a file matching the paths: pattern
2. Ask agent to modify it
3. Verify agent mentions or follows the rule
4. If global rule, verify it appears in all contexts

Verification:
- Rule activates when working on matching files
- Agent follows the conventions in the rule

Red Flags - STOP

These thoughts mean you're rationalizing. STOP and reconsider:

  • "This should be in CLAUDE.md, but I'll make it a rule" (scope for relevance, not to hide it)
  • "paths: gates the load so size doesn't matter" (a matched rule is still fully resident afterward — keep it small)
  • "Skip paths:, it's just documentation" (false — it is a real load gate; omitting it makes the rule always-resident)
  • "50 lines is too restrictive"
  • "Skip baseline, I know what's needed"
  • "Add how-to instructions here" (rule = directive, skill = procedure)
  • "One big rule is better than multiple small ones"
  • "Writing 'NEVER force-push' in a rule will stop it" (it won't — rule = ~70% suggestion; use a hook for hard stops)
  • "I need to explain the steps" (that is a skill, not a rule)
  • "Let me add a code example" (a rule is a directive, not a tutorial)

All of these mean: You're about to create a weak rule. Follow the process.

Common Rationalizations

Excuse Reality
"CLAUDE.md is overkill" If it applies broadly to all work, it belongs in CLAUDE.md.
"Unscoped rules are fine" Unscoped = loaded at launch in every session, forever. Add paths:.
"50 lines is arbitrary" Long rules dilute adherence, and unscoped ones bill every session.
"I can add procedures here" Rules = what. Skills = how. Keep them separate.
"One comprehensive rule" Multiple focused rules > one bloated rule.

References

  • references/paths-patterns.md - Glob pattern syntax for paths: scope tags
  • references/examples.md - Rule examples by domain (includes Safety Bypass Prevention baseline templates for git / deploy / destructive ops)

常见问题

5 问
答案由本站依据条目字段整理
writing-rules怎么安装?

没有现成安装命令:按安装说明或仓库 README,把 SKILL.md 放进客户端的 skills 目录(一般一个技能一个文件夹)。

writing-rules支持哪些客户端?

资料没有标注宿主客户端,但只要客户端支持 Skills(Claude、Codex、Cursor 等),一般都能加载。

writing-rules权限高吗,安全吗?

权限级别为未标注权限。安装前先看它会读取或写入哪些内容。

writing-rules收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于技能本身和所用的模型或客户端,正式使用前按作者说明确认。

writing-rules用什么许可证?

许可证标注为 未说明(许可证不明确)。商用或二次分发前请到仓库确认条款原文。

热门专题

按场景挑技能
全部专题 →

技能内容以作者仓库为准;分类、权限级别与许可证状态的中文说明为中文整理,最近核验 未标注。