| name | rule-file-writing |
| version | 3.4.0 |
| description | Use when creating or optimizing a rule file for per-token behavioral steering. Rule files are instruction files that an AI coding assistant automatically loads for a matching user, project, or directory scope; they are NOT skills, agents, or commands. Trigger on "write a rule about X", "create a rules file", "optimize this rules file", "cut ballast from this rule file", or any request to author or refine an auto-loaded file whose purpose is persistent behavioral steering. |
| allowed-tools | Read, Write, Edit, Glob, Grep, AskUserQuestion |
Rule-File Writing and Optimization
Core Principle
A rule file is an instruction file that an AI coding assistant automatically loads for a matching user, project, or directory scope. It supplies persistent behavioral steering rather than a task-specific workflow.
Rule files are context tax paid whenever their scope matches. Optimize for behavioral steering per token: keep what changes generation, cut what justifies the rule to a human reader.
This skill covers rule files only. For skills, agents, or commands, use the corresponding authoring workflow. For SKILL.md or agent content, defer to content-editing.
Mode Detection
- Create โ triggers: "write a rule about X", "create a rules file", "add a rule for Y", or any request that names a rule without pointing at an existing file. Interview the user (or skip if the conversation already supplies the content), then draft from the template using the active assistant's rule-file convention.
- Optimize โ triggers: "optimize this rules file", "cut ballast from this rule file", "clean up this rule", or any invocation that supplies a path to an existing rule file. Run the two-pass loop.
Create Workflow
Step 1: Interview
Skip this step if the conversation already contains (a) the rule, (b) the failure mode it prevents, (c) the triggering action, (d) plausible bypass rationalizations, and (e) the target path.
Otherwise ask the user one question at a time, with multiple-choice options where possible:
- Rule in one sentence โ
CRITICAL opener.
- Triggering action โ
Decision Test heading.
- 2โ4 WRONG/CORRECT pairs โ body code block. Skip if the rule has no syntactic form.
- 2โ4 bypass rationalizations โ Red Flags table.
- Allowed exceptions โ gated escape hatch section. Omit if none.
- Target path and scope. Use the active assistant's documented rule-file convention; do not invent a location.
Step 2: Draft From Template
- Read
assets/templates/rules-file-skeleton.md.
- Fill slots from interview answers or conversation context.
- Remove
## Banned Patterns if the rule has no syntactic form.
- Remove
{{OPTIONAL_ALLOWED_EXCEPTIONS_SECTION}} if there are no exceptions โ no empty heading.
- Default
{{BODY_SECTION_TITLE}} to ## Core Rules unless a more specific frame applies.
- Save to the target path.
Minimum viable output: CRITICAL opener + Decision Test + body + Red Flags.
Step 3: Present
Show the draft to the user for a sanity check before entering the optimize workflow.
Optimize Workflow
Two fixed passes. No third pass โ if the user wants more, they re-invoke.
Pass 1: Content Cuts
- Read
references/essential-vs-ballast.md for the classification tables and the per-paragraph decision test.
- Read the target file end-to-end.
- Classify each paragraph/bullet as essential or ballast. Apply the calibrated-honesty gate from the reference to every proposed cut.
- Apply cuts. Report the word-count delta.
Pass 2: Structural Alignment
- Read
references/techniques.md and references/three-angle-pattern.md.
- Run the Pass 2 scan checklist from
techniques.md (family-pattern order, front-loaded decision gate, code-block framing, WHY clauses, explicit gate conditions).
- Apply the three-angle check. Add missing angles only to bypass-prone rules, never to non-rationalizable ones.
- Apply edits. Report the trajectory:
original โ Pass 1 โ Pass 2.
Honest Reporting
If two passes produce minimal cuts, report 0% and stop. Manufactured cuts are banned โ the calibrated-honesty gate in essential-vs-ballast.md enforces this. Expected reduction ranges:
| File state | Expected Pass 1 + Pass 2 reduction |
|---|
| Heavy ballast (essay-style, citations, "why" sections) | 40โ55% |
| Moderately tight | 10โ25% |
| Already tight (authored with these principles) | 1.5โ10% |
| Already optimal | 0% โ report honestly |
Error Handling
- Target is not an auto-loaded rule file for the active assistant โ wrong skill; use the corresponding content-authoring workflow
- Target rules file does not exist and no content is provided โ run Step 1 (Interview)
- Target path is not recognized by the active assistant's rule discovery conventions โ confirm the path before writing