-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehavior.mdc
More file actions
executable file
·107 lines (76 loc) · 4.64 KB
/
behavior.mdc
File metadata and controls
executable file
·107 lines (76 loc) · 4.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
description: Principles for minimizing frequent LLM coding errors. Apply during code creation, review, or updates to keep solutions simple, clarify underlying assumptions, focus changes precisely, and establish clear, testable goals.
alwaysApply: true
---
# Behavioral guidelines
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.
## 1. Think Before Coding
**Don't assume. Don't hide confusion. Surface tradeoffs.**
Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.
## 2. Simplicity First
**Minimum code that solves the problem. Nothing speculative.**
- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.
Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.
## 3. Surgical Changes
**Touch only what you must. Clean up only your own mess.**
When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.
When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.
The test: Every changed line should trace directly to the user's request.
## 4. Goal-Driven Execution
**Define success criteria. Loop until verified.**
Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"
For multi-step tasks, state a brief plan:
```
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
```
Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.
## 5. Formatting
**No em dashes. Ever.**
- Never use the "—" character (em dash) in any output, whether code, comments, commit messages, PR descriptions, prose or answers.
- Use a comma, semicolon, or rewrite the sentence instead.
## 6. Commits and PRs
**Follow conventional commits. Write for the reviewer, not yourself.**
Commit messages:
- Always use a prefix: `fix:`, `feat:`, `chore:`, `chore(deps):`, etc.
- Subject line is lowercase after the prefix, concise, imperative mood.
- Body explains *why* the change was made and *what was wrong*, not a line-by-line narration of what changed.
- Version-only commits use `[no ci]` in the subject.
Pull requests:
- Title uses the same prefix format as commits.
- Body starts with `## Summary` followed by `-` bullet points.
- Never use checkboxes or checkmarks in the body.
- Add `## Context` when the reader needs background that isn't obvious from the diff.
- Use backticks for class names, method names, config keys, and paths.
- State facts: what was wrong, what changed, why. No hedging ("this should fix", "hopefully resolves").
- When multiple files are touched for different reasons, use a markdown table or subsections to explain each.
Git operations:
- Never force-push (`--force`, `--force-with-lease`) unless the user explicitly requests it.
- Prefer creating a new commit over amending when changes have already been pushed.
## 7. Debugging
**When unsure, ask. Guessing wastes everyone's time.**
- If you are not 100% sure about the root cause, say so. Propose two or three hypotheses and ask the user which to investigate first.
- Suggest concrete ways to gather evidence: log output, a specific command, a breakpoint location, a config value to check. "How should we confirm this?" is a good default question.
- Never silently assume a fix is correct. State what you changed, what you expect to happen, and how to verify.
- If the user says "I don't know", that is a valid answer. Pivot to the next most useful diagnostic step instead of repeating the question.
- Prefer the smallest experiment that rules out a hypothesis. One targeted curl, one log grep, one env-var check, before broad sweeps.
- When multiple services or layers are involved, narrow the blast radius first: identify which component owns the error before diving into code.