Intermediate
Best Claude Prompt for Write Features
Why Claude?
Claude produces the highest-quality code among all AI tools — it understands architecture context, reasons about trade-offs, follows existing patterns, and generates production-ready code with minimal hallucination. Best when you describe system design intent, not just syntax.
Prompt Template
<role>
You are a senior software engineer. Write clean, production-ready code that follows the existing codebase conventions and solves exactly the stated problem — nothing more.
</role>
<code_context>
Language/framework: {{language_framework}}
Existing patterns in this codebase: {{existing_patterns}}
Relevant file(s): {{relevant_files}}
</code_context>
<task>
Feature to implement: {{feature_description}}
Requirements:
{{requirements}}
Constraints:
- Match the naming conventions and code style already present
- Do not introduce new dependencies unless absolutely necessary
- Handle edge cases: {{edge_cases}}
</task>
After writing the code, briefly explain your key design decisions in 3 bullet points. Be honest about uncertainty if any requirement is ambiguous. Example Output
```python
# src/auth/rate_limiter.py
import logging
Show full example
from fastapi import Request, HTTPException
from redis.asyncio import Redis
logger = logging.getLogger(__name__)
RATE_LIMIT_PREFIX = "login_attempt:"
MAX_ATTEMPTS = 5
WINDOW_SECONDS = 900
async def check_login_rate_limit(request: Request, redis: Redis) -> None:
ip = request.headers.get("X-Forwarded-For", request.client.host).split(",")[0].strip()
key = f"{RATE_LIMIT_PREFIX}{ip}"
try:
attempts = await redis.incr(key)
if attempts == 1:
await redis.expire(key, WINDOW_SECONDS)
if attempts > MAX_ATTEMPTS:
ttl = await redis.ttl(key)
raise HTTPException(status_code=429, headers={"Retry-After": str(ttl)}, detail="Too many login attempts")
except HTTPException:
raise
except Exception as e:
logger.warning(f"Rate limiter Redis error (fail open): {e}")
```
Key decisions:
- Fail open on Redis error to avoid locking out users during infrastructure issues
- X-Forwarded-For split on comma handles load balancer chains
- TTL set only on first increment to avoid sliding window behavior
Make it yours
Your Generated Prompt
Prompt copied! What's next?
Got your AI output? Make it better.
Paste what Claude generated into Coda One — free, no signup.
Tips for Better Results
Paste the actual file contents into {{relevant_files}} for best results. Claude respects existing patterns when it can see them. For multi-file features, list all affected files upfront.
Example (filled in)
<role>
You are a senior software engineer. Write clean, production-ready code that follows the existing codebase conventions and solves exactly the stated problem — nothing more.
</role>
<code_context>
Language/framework: Python 3.11 / FastAPI
Existing patterns in this codebase: repository pattern, dependency injection via constructor, async/await throughout
Relevant file(s): src/auth/router.py, src/auth/service.py
</code_context>
<task>
Feature to implement: Add rate limiting to the POST /login endpoint — max 5 attempts per IP per 15 minutes.
Requirements:
- Track attempts in Redis with TTL
- Return HTTP 429 with Retry-After header when limit exceeded
- Reset counter on successful login
Constraints:
- Match the naming conventions and code style already present
- Do not introduce new dependencies unless absolutely necessary
- Handle edge cases: Redis connection failure (fail open, log warning), IPv6 addresses, requests behind reverse proxy (X-Forwarded-For)
</task>
After writing the code, briefly explain your key design decisions in 3 bullet points. Be honest about uncertainty if any requirement is ambiguous.