/wordsmith:writing-effective-rulesfrom wordsmith
Use before creating or changing Claude Code rules, and when reviewing them, including files in `.claude/rules/` and `~/.claude/rules/`.
Ships in wordsmith. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A rule changes what Claude does in a specific situation. Give each rule the shape its content needs: a one-line convention stays one line, and a boundary with a tempting violation gets an example. Rule files have no standard template.
Create or change a rule file only when the user explicitly asks for that change. Neither of these counts as a request:
If a change makes a rule false, or you find knowledge that might belong in a rule, leave the file unchanged. Tell the user, and propose the exact edit.
Name the repeated mistake or ambiguity the instruction prevents. If you cannot name one, raise that with the user instead of writing the rule.
Then pick the home that fits. Write a rule only if none of these apply:
Every rule conveys three things, with or without headings.
Instruction. Open the file with it. State the target behaviour rather than only the banned one. Describe what it covers as a pattern, not a list of current members: "every handler under src/api/", not "the users, orders, and billing handlers". A list goes stale when someone adds a member, and the rule then stops covering the new one without anyone noticing. Match the wording to the real strictness:
must, and give no exceptions.Scope. Use paths frontmatter when the scope is file-based:
---
paths:
- "src/api/**/*.ts"
- "lib/**/*.ts"
---
paths loads when Claude reads or edits a matching file. If the rule must shape a decision made before Claude touches such a file, leave out paths.paths loads every session and costs context every session, so reserve this for instructions that apply to most work.paths is the only frontmatter field Claude Code reads from a rule. If the YAML does not parse, the rule loads as if it had no paths.Reason. Say what goes wrong without the rule, so Claude can handle cases the rule does not foresee. Omit the reason only when it is self-evident.
Each device below is optional. Most rules need one at most.
| Device | Use when | Skip when |
|---|---|---|
| Example | The correct shape is hard to describe in words | One sentence states the shape exactly |
| Wrong and right contrast | Claude is likely to choose a specific wrong approach | The wrong approach only negates the instruction |
| Ordered steps | The order matters and there are a few steps | The procedure is long enough to be a skill |
| Checklist | Several separate conditions must be verified | The rule has one condition |
| Headings | The rule has several parts to navigate | The rule fits on one screen |
Prefer a short copied snippet for an example, cut to the smallest size that shows the shape. Use a file reference when the example is too long to copy, and remember that references break when files move.
Write checklist items that a reviewer can answer yes or no by inspecting imports, files, behaviour, commands, or tests:
- [ ] The service does not import from `adapters`.
- [ ] HTTP integration tests use `testutil.NewIntegrationTestServer`.
Items such as "Code is clean" or "Tests are enough" cannot be verified, so rewrite them or delete them.
These samples show the range. They are not templates.
A single convention:
---
paths:
- "db/migrations/**"
---
Name migrations `YYYYMMDD_description.sql`. The deploy job applies them in filename order, so any other format runs out of sequence.
A boundary with a tempting violation:
---
paths:
- "internal/services/**"
---
Services must depend on interfaces in `internal/ports`. Tests replace adapters through these interfaces, so a direct import forces the test to run against a real database.
```go
// Wrong
import "app/internal/adapters/postgres"
// Right
func NewBilling(store ports.InvoiceStore) *Billing
```
A scope that is not file-based, with several conditions to verify:
When you add a public HTTP endpoint, describe it in the OpenAPI spec. CI generates client SDKs from the spec, so customers cannot call an endpoint that it omits.
- [ ] `api/openapi.yaml` describes the endpoint and its error responses.
- [ ] `make generate-sdk` ran, and its output is committed.
- [ ] An integration test calls the endpoint through `testutil.NewIntegrationTestServer`.
Split a rule when it covers more than one concern. Give the file a descriptive name, such as api-design.md. Delete any line Claude already follows by default, and any line that does not prevent a likely mistake.
CLAUDE.md. Match local conventions, and resolve any conflict, because Claude can follow either side of a contradiction.What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/comment-disciplineUse when writing, editing, or reviewing code or config in any language, including IaC and manifests, to decide whether a comment belongs and how to word it./document-disciplineUse before creating or changing documentation, including READMEs, `docs/` files, runbooks, and design documents, or when deciding whether knowledge from a task should be written down./writing-effective-agents-mdUse before creating or changing `AGENTS.md` or `CLAUDE.md` files, and when reviewing them.Other plugins' skills for the same job
npx claudepluginhub davidnlopes/claude-code-plugins --plugin wordsmith