Specificity: Why 'Write a Function' Fails and 'Write a Function That…' Works
Specific prompts produce useful output; vague prompts produce vague output.
What You Will Learn
- Recognize the specificity ladder.
- Upgrade vague prompts into specific ones.
- Use constraints, examples, and context.
- Avoid over-specifying into micromanagement.
- Measure the impact of specificity.
Why This Matters
A vague prompt is a slot machine — sometimes good, often bad. A specific prompt is a precision tool. The difference between 'write a function' and 'write a TypeScript function that takes a Date and returns an ISO 8601 string in UTC, throwing on invalid input' is the difference between useless and useful.
Concept Explained
Specificity is the practice of telling Claude exactly what you want: inputs, outputs, constraints, conventions, examples, edge cases. The specificity ladder goes from one-word prompts ('sort') to fully-specified prompts with examples and constraints.
How It Works
Specificity works because it narrows Claude's probability distribution. 'Write a function' could mean thousands of things; 'write a TypeScript function that takes a Date and returns an ISO 8601 UTC string, throwing on invalid input' means essentially one thing.
Step-by-Step Tutorial
1. Identify vague prompts
Spot prompts like 'do this', 'fix', 'add tests'. They're too vague.2. Apply the specificity ladder
Add: input types, output types, constraints, edge cases, examples, conventions.3. Use constraints
'Don't use external libraries', 'must handle null', 'throw on invalid'.4. Provide examples
One example often beats ten constraints.5. Stop before micromanaging
Don't dictate implementation step-by-step.Real-World Example
A developer asked Claude to 'write a function to validate email'. Got a 30-line regex monster. Upgraded: 'write a TypeScript function isValidEmail(s: string): boolean that returns true for RFC 5322-compliant emails, false otherwise, no external dependencies, with a single test case showing it accepts user@example.com and rejects user@'. Got a clean 5-line function.
Example Prompts / Commands / Code
Level 0 (vague): 'write a sort function'
Level 1: 'write a TypeScript function that sorts an array of numbers ascending'
Level 2: 'write a TypeScript function sortAsc(nums: number[]): number[] that returns a new sorted array, doesn't mutate input, throws on null'
Level 3: same as Level 2 + 'use quicksort, here's an example: sortAsc([3,1,2]) → [1,2,3]'
Level 4 (micromanage): 'write a sort function. Define a function called sortAsc. Take one parameter called nums. Use quicksort. The pivot should be the middle element...' ← TOO MUCH
Common Mistakes
- Stopping at Level 0 or 1 — too vague.
- Jumping to Level 4 — micromanaging kills Claude's pattern-matching value.
- Adding constraints without examples.
- Specifying implementation instead of behavior.
Best Practices
- Aim for Level 2–3: types, constraints, one example.
- Specify behavior, not implementation.
- Use examples to clarify ambiguous constraints.
- Iterate: start specific, add more if needed.
Troubleshooting
| Problem | How to Fix |
|---|---|
| Output still wrong despite specificity | Try a different model. Or attach a reference file. |
| Output feels generic | Add a constraint or an example. |
Practical Exercise
Your Turn
Take a vague prompt you've used ('add error handling'). Rewrite at Level 2 (types + constraints) and Level 3 (with example). Compare outputs.
Key Takeaways
- Specificity = telling Claude exactly what you want.
- Ladder: vague → typed → constrained → with example.
- Aim for Level 2–3.
- Specify behavior, not implementation.
- One example often beats ten constraints.
Frequently Asked Questions
How specific is too specific?
Should I always provide examples?
Does specificity cost more?
Further Reading
Official References
SEO Metadata
SEO title: Specificity: Why 'Write a Function' Fails and 'Write a Function That…'
Meta description: Specific prompts produce useful output; vague prompts produce vague output.
Primary keyword: claude prompt specificity
Secondary keywords: claude specific prompts, claude prompt examples, claude vague prompts
Search intent: Informational
URL slug: /claude-specificity-ladder
Categories: AI Tools, Claude
Tags: Claude, Beginner, Prompting, Specificity, IMCSEIAN, Tutorial, IMCSEIAN
Featured image concept: Ladder diagram showing prompt specificity levels.
Comments
Comments
Post a Comment