Skip to content

Commit c406cba

Browse files
aster-voidclaude
andcommitted
modules/claude-code: improve ai-docs skill
- Truncate and restructure for clarity - Add followable workflow section with concrete NixOS example - Add TDD principle - Note negative framing OK when prohibiting 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 949fbea commit c406cba

File tree

1 file changed

+46
-88
lines changed
  • modules/home/profile-dev/programs/claude-code/skills/ai-docs

1 file changed

+46
-88
lines changed

modules/home/profile-dev/programs/claude-code/skills/ai-docs/SKILL.md

Lines changed: 46 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -5,121 +5,79 @@ description: ALWAYS use this skill when writing AI documentation. Covers CLAUDE.
55

66
# AI Documentation Skill
77

8-
## Research-Backed Principles (2024-2025)
9-
10-
### What Works
11-
12-
| Technique | Why | Source |
13-
|-----------|-----|--------|
14-
| **XML tags** | Claude trained on XML; improves parsing & structure | Anthropic docs |
15-
| **Templates with `{placeholders}`** | More reliable than prose instructions | Prompt engineering research |
16-
| **Concise + sufficient context** | >3000 tokens degrades reasoning | LLM length studies |
17-
| **Few-shot examples (1-3)** | Biggest gain is 0→1 example; diminishing returns after | Few-shot research |
18-
| **Positive framing** | "Do X" reduces ambiguity vs "Don't do X" | PromptHub studies |
19-
| **Explicit output format** | JSON/list/structure specification improves accuracy | Multiple studies |
20-
| **Task decomposition** | One prompt = one task | Overload research |
21-
22-
### What Doesn't Work
23-
24-
| Anti-Pattern | Problem | Research Finding |
25-
|--------------|---------|------------------|
26-
| **Vague prompts** | Forces AI to guess → generic output | Universal finding |
27-
| **Overloaded prompts** | Multiple tasks = quality degradation | Task complexity studies |
28-
| **Heavy persona prompting** | <10% variance explained for accuracy tasks | ACL 2024: Persona Effect |
29-
| **Long verbose prompts** | Recency bias; vaguer responses | Length impact studies |
30-
| **Negative instruction lists** | "Don't do X" underperforms "Do Y" | PromptHub research |
31-
| **Contradicting instructions** | Common in long system prompts | Best practices guides |
32-
33-
### Claude-Specific
34-
35-
- Claude weighs **user messages > system prompts** (unlike GPT)
36-
- XML tags like `<instructions>`, `<example>`, `<thinking>` are optimal
37-
- Nest tags for hierarchy: `<outer><inner></inner></outer>`
38-
- Be consistent with tag names; reference them in instructions
8+
## Core Principles
9+
10+
| Do | Don't |
11+
|----|-------|
12+
| XML tags (`<rules>`, `<workflow>`) | Prose paragraphs |
13+
| Templates: `{placeholder}` | Vague instructions |
14+
| Positive: "Do X" | Negative: "Don't Y" (unless prohibiting) |
15+
| One task per prompt | Overloaded prompts |
16+
| Observable output | Internal instructions ("mentally X") |
17+
| Concrete examples | Abstract rules |
18+
| <3000 tokens | Long verbose docs |
19+
| TDD: tests first | Implementation first |
3920

4021
## Document Template
4122

4223
```markdown
43-
<settings>
44-
key = value
45-
</settings>
46-
4724
<rules>
48-
1. [Rule]: [concrete example]
49-
- `good example` not `bad example`
25+
1. [Rule]: `good` not `bad`
5026
</rules>
5127

5228
<workflow>
53-
Template with {fill_in_placeholders}:
54-
- [Decision] {condition} → {action}
29+
1. {step with placeholder}
30+
2. [Decision] {cond} → {action}
5531
</workflow>
5632

5733
<tools>
58-
tool-name = constraint or usage tip
34+
tool = gotcha or constraint
5935
</tools>
60-
61-
<tips>
62-
- [Actionable tip with example]
63-
</tips>
6436
```
6537

6638
## Writing Rules
6739

68-
### Structure Over Prose
6940
```
70-
BAD: "You should try to keep your commit messages clear and descriptive"
71-
GOOD: Commit: `{scope}: {description}` (e.g., `modules/git: add hooks`)
41+
Structure: BAD "keep commits clear" → GOOD `{scope}: {msg}`
42+
Positive: BAD "Don't cd" → GOOD "Stay at repo root"
43+
Concrete: BAD "reasonably sized" → GOOD "~100 lines"
44+
Observable: BAD "mentally verify" → GOOD "output: Task, Constraints, Verify"
45+
Decision: [Decision] simple → exec | complex → breakdown
7246
```
7347

74-
### Positive Over Negative
75-
```
76-
BAD: "Don't use cd commands"
77-
GOOD: "Stay at repo root. Use relative/absolute paths."
78-
```
48+
## Followable Workflows
7949

80-
### Concrete Over Abstract
81-
```
82-
BAD: "Keep files reasonably sized"
83-
GOOD: "Target ~100 lines/file. Split when exceeding."
84-
```
50+
AI docs should include **step-by-step workflows** AI can mechanically follow.
8551

86-
### Decision Markers
87-
```
88-
[Decision] simple task → execute | complex task → break down first
89-
[Decision] {condition} → {action A} | {otherwise} → {action B}
90-
```
52+
- Numbered steps, single action each
53+
- `[Decision] {cond} → {action}` for branches
54+
- `{placeholder}` for fill-ins
9155

92-
## Content Guidelines
56+
example:
9357

94-
**Include** (project-specific, non-obvious):
95-
- Conventions: commit format, file naming, directory rules
96-
- Constraints: "never X", "always Y before Z"
97-
- Decision templates with conditions
98-
- Tool-specific gotchas
58+
```markdown
59+
<workflow>
60+
## Adding a NixOS Module
61+
1. Create `modules/{home|nixos}/{name}/default.nix`
62+
2. Add option: `my.{name}.enable = lib.mkEnableOption "{name}";`
63+
3. [Decision] multiple configs → use collectFiles | single → inline
64+
4. Import in parent default.nix
65+
5. Verify: `nix flake check`
66+
</workflow>
67+
```
9968

100-
**Exclude** (AI already knows or can find):
101-
- Generic best practices
102-
- Tool documentation
103-
- Code explanations (AI reads code)
104-
- Tutorials
69+
Anti-pattern: "Create appropriate module structure based on your judgment"
10570

106-
## Length Guidelines
71+
## Content & Length
10772

108-
| Document | Target | If Exceeded |
109-
|----------|--------|-------------|
110-
| CLAUDE.md | 50-150 lines | Split into skills |
111-
| Skills | 50-100 lines | Split into sub-skills |
112-
| Inline comments | 1 line | Rare exceptions for complex WHY |
73+
**Include:** conventions, constraints, decision templates, tool gotchas
74+
**Exclude:** generic best practices, tool docs, code explanations
11375

114-
Reasoning: >3000 tokens measurably degrades LLM reasoning quality.
76+
| Doc | Lines |
77+
|-----|-------|
78+
| CLAUDE.md | 50-150 |
79+
| Skills | 50-100 |
11580

11681
## Checklist
11782

118-
Before finalizing AI documentation:
119-
1. Using XML tags for structure?
120-
2. Templates have `{placeholder}` syntax?
121-
3. All instructions positive framing?
122-
4. Decision points marked with `[Decision]`?
123-
5. Concrete examples for every rule?
124-
6. Under length limit?
125-
7. No redundant info AI can infer?
83+
1. XML tags? 2. `{placeholders}`? 3. Positive framing? 4. `[Decision]` markers? 5. Examples? 6. Under limit?

0 commit comments

Comments
 (0)