$npx -y skills add DevelopersGlobal/ai-agent-skills --skill think-before-codingForces explicit reasoning before writing any code. Surfaces assumptions, manages confusion, and prevents hallucination by demanding clarity upfront.
| 1 | ## Overview |
| 2 | |
| 3 | AI agents default to writing code immediately — even when the request is ambiguous, the context is incomplete, or multiple valid interpretations exist. This skill forces a deliberate thinking phase before any implementation begins. |
| 4 | |
| 5 | The result: fewer rewrites, fewer wrong-direction implementations, and fewer "I assumed X" surprises. |
| 6 | |
| 7 | ## When to Use |
| 8 | |
| 9 | Activate this skill **before writing any code** when: |
| 10 | - The request is ambiguous or underspecified |
| 11 | - Multiple valid implementations exist |
| 12 | - You are unsure about an existing system's constraints |
| 13 | - The task touches security, data integrity, or public APIs |
| 14 | - You feel the urge to "just start coding" to make progress |
| 15 | |
| 16 | ## Process |
| 17 | |
| 18 | ### Phase 1: Understand the Request |
| 19 | |
| 20 | 1. **Read the full request** — Do not skim. Re-read once. |
| 21 | 2. **Identify ambiguities** — List every decision you would have to make silently: |
| 22 | - What counts as "success"? |
| 23 | - What are the inputs and expected outputs? |
| 24 | - What should NOT change? |
| 25 | - Are there existing patterns to follow? |
| 26 | 3. **Surface assumptions** — Write them out: *"I am assuming X because Y."* |
| 27 | 4. **Check for contradictions** — Does the request contradict itself or existing code? |
| 28 | |
| 29 | **Verify:** Can you state the goal in one clear sentence? If not, ask before proceeding. |
| 30 | |
| 31 | ### Phase 2: Clarify Before Acting |
| 32 | |
| 33 | 5. If **genuinely ambiguous**, ask a focused clarifying question — not a list of 10 questions. Pick the one blocker. |
| 34 | 6. If multiple valid approaches exist, **present 2–3 options with tradeoffs**, then ask which to proceed with. |
| 35 | 7. If something seems wrong with the request, **say so directly** — don't silently work around it. |
| 36 | |
| 37 | **Verify:** You have a clear, agreed-upon interpretation of the task. |
| 38 | |
| 39 | ### Phase 3: State Your Plan |
| 40 | |
| 41 | 8. Before writing code, state: |
| 42 | - What you will build |
| 43 | - What you will NOT touch |
| 44 | - What success looks like (your verification criteria) |
| 45 | 9. For multi-step tasks, write a brief plan: |
| 46 | ``` |
| 47 | 1. [Step] → verify: [check] |
| 48 | 2. [Step] → verify: [check] |
| 49 | 3. [Step] → verify: [check] |
| 50 | ``` |
| 51 | |
| 52 | **Verify:** The plan is agreed upon, or you have received approval to proceed. |
| 53 | |
| 54 | ### Phase 4: Code |
| 55 | |
| 56 | 10. Now write the code — following the plan exactly. |
| 57 | |
| 58 | ## Common Rationalizations (and Rebuttals) |
| 59 | |
| 60 | | Excuse | Rebuttal | |
| 61 | |--------|----------| |
| 62 | | "I'll figure it out as I go" | Unknown unknowns compound. 5 minutes of thinking saves 50 minutes of rewriting. | |
| 63 | | "The request is clear enough" | If you can't state the goal in one sentence, it's not clear enough. | |
| 64 | | "Asking questions slows things down" | Wrong direction is infinitely slower than a 30-second clarifying question. | |
| 65 | | "I'll handle edge cases later" | Edge cases not considered upfront become bugs found in production. | |
| 66 | | "I can always refactor" | You almost never will. Design now. | |
| 67 | |
| 68 | ## Red Flags |
| 69 | |
| 70 | - You're already writing code and you haven't stated what success looks like |
| 71 | - You made a silent assumption about what the user wants |
| 72 | - You chose between two approaches without mentioning the tradeoff |
| 73 | - You're solving a problem the user didn't ask about |
| 74 | - You're 100 lines in and realize you misunderstood the goal |
| 75 | |
| 76 | ## Verification |
| 77 | |
| 78 | Before leaving this phase, confirm: |
| 79 | - [ ] The goal is stated in one clear sentence |
| 80 | - [ ] All major assumptions are explicitly named |
| 81 | - [ ] Ambiguities are resolved (or flagged for the user) |
| 82 | - [ ] A brief plan exists with verification criteria per step |
| 83 | - [ ] You know what you will NOT touch |
| 84 | |
| 85 | ## References |
| 86 | |
| 87 | - [Andrej Karpathy on LLM coding pitfalls](https://x.com/karpathy/status/2015883857489522876) |
| 88 | - [goal-driven-execution skill](../goal-driven-execution/SKILL.md) |
| 89 | - [idea-to-spec skill](../idea-to-spec/SKILL.md) |