_template — Claude Code rule: structure and installation
_template — a rule-file scaffold with fields for its title and impact, plus sections for contrasting incorrect and correct code.
no license ★ 1,064 updated 2026-01-21
.claude/rules/_template.mdWhat _template does
_template is a file outline, not a ready-made instruction for an agent. It provides space for a title, an impact level, a short rationale, contrasting code samples, and a reference link. Replace the sample labels and code with details from the rule you want to write.
For Claude Code, put the file at .claude/rules/_template.md. Placeholders such as Rule Title Here and example() do not define a specific agent behavior. Write the rule itself before using the scaffold as a project instruction.
What it helps with
- create an outline for a rule file
- record a rule’s impact and rationale
- contrast incorrect and correct code
- add a reference link to a rule
Example prompts for the agent
- Draft a Claude Code rule about error handling using
_template. - Fill in
_templatewith a rule for code formatting and replace its sample content. - Create a rule file that compares incorrect and correct code using the
_templatestructure.
How to install _template
Manually: put the files in place
.claude/rules/_template.mdThe paths frontmatter field limits the files
AGENTS.md
Codex reads AGENTS.md: paste the rule text there
Manually: put the files in place
.cursor/rules/_template.mdcFrontmatter: description, globs, alwaysApply
Manually: put the files in place
.github/instructions/_template.instructions.mdThe applyTo field sets which files it applies to
Manually: put the files in place
.devin/rules/_template.mdManually: put the files in place
.clinerules/_template.mdStep by step, with commands for each platform: AGENTS.md vs CLAUDE.md: what they are and which one to use
Questions about _template
How do I install _template in Claude Code?
Place the file in your project at .claude/rules/_template.md. Then replace the sample title, explanation, and code with the content of your rule.
What does _template do?
It provides a layout for a rule file, including an impact field and sections for contrasting code examples. It does not define a specific agent behavior on its own.
What should I replace in _template?
Replace the sample headings, explanation, code snippets, and reference link with material for your rule. The placeholders do not describe a concrete rule.