Your First Tasks
Let’s walk through common tasks you’ll do with Claude Code. These examples use Python, but the patterns apply to any language.
Task 1: Understand Unfamiliar Code
Section titled “Task 1: Understand Unfamiliar Code”You’ve just joined a project. Start here:
> explain this codebase at a high level
> what are the main entry points?
> draw a diagram of how the components interactDeep Dive on Specific Code
Section titled “Deep Dive on Specific Code”> walk me through what happens when a user logs in
> explain the User model and its relationships
> what's the purpose of the middleware in app.py?Task 2: Fix a Bug
Section titled “Task 2: Fix a Bug”The best bug fix prompts include context:
Good:
> users report that password reset emails aren't being sent.> the error in the logs is "SMTP connection refused"> find and fix the issueEven Better:
> users report that password reset emails aren't being sent> this started happening after yesterday's deployment> the error in the logs is "SMTP connection refused"> we use SendGrid for email> find and fix the issueLet Claude Investigate
Section titled “Let Claude Investigate”> the checkout flow is broken but I don't know why> run the tests and help me figure out what's wrongClaude will:
- Run your test suite
- Analyze failures
- Trace the issue to source
- Propose a fix
Task 3: Write Tests
Section titled “Task 3: Write Tests”> write pytest unit tests for the UserService class> focus on edge cases and error conditions> write integration tests for the /api/users endpoint> test all HTTP methods and status codes> this function has no tests, add comprehensive coverage:> [paste function or point to file]Test Example Session
Section titled “Test Example Session”claude > write tests for the payment processing module
I'll create comprehensive tests for payments.py. Here's my plan:
1. Test successful payment processing2. Test insufficient funds handling3. Test invalid card data4. Test network timeout recovery5. Test idempotency (duplicate requests)
Creating tests/test_payments.py...
claude > run them
Running: pytest tests/test_payments.py -v
test_successful_payment PASSEDtest_insufficient_funds PASSEDtest_invalid_card PASSEDtest_network_timeout PASSEDtest_idempotency FAILED # Oops, found a bug!
The idempotency test failed. Looking at the code, I see thatduplicate requests aren't being handled. Want me to fix this?Task 4: Refactor Code
Section titled “Task 4: Refactor Code”Tell Claude what you want to achieve:
> refactor the database module to use connection pooling
> this function is 200 lines long, break it into smaller functions
> convert this class to use async/await
> extract the validation logic into a separate moduleRefactor with Constraints
Section titled “Refactor with Constraints”> refactor the auth module> constraints:> - don't change the public API> - keep backward compatibility> - add type hintsTask 5: Add a Feature
Section titled “Task 5: Add a Feature”For larger features, use plan mode (press Alt+M to cycle to plan mode):
> add a user notification system
Claude will ask:- What types of notifications? (email, push, in-app)- What events trigger notifications?- Should users be able to configure preferences?- What's the delivery mechanism?Feature Implementation Flow
Section titled “Feature Implementation Flow”claude > add rate limiting to the API
Let me understand the requirements:
1. What endpoints need rate limiting? ○ All endpoints ○ Only authenticated endpoints ○ Specific endpoints (list them)
[You select: Only authenticated endpoints]
2. What rate limit strategy? ○ Fixed window (e.g., 100 requests per minute) ○ Sliding window ○ Token bucket
[You select: Fixed window]
3. Where should limits be stored? ○ In-memory (resets on restart) ○ Redis (persistent across instances)
[You select: Redis]
Great, here's the plan:
1. Add redis-py to requirements.txt2. Create rate_limiter.py with RateLimiter class3. Add rate_limit decorator4. Apply to authenticated routes5. Add tests6. Update API documentation
Proceed with implementation?Task 6: Review Code
Section titled “Task 6: Review Code”> review my changes before I commit
> are there any security issues in the auth module?
> check for performance problems in the database queries
> is this code following our style guide?Task 7: Documentation
Section titled “Task 7: Documentation”> add docstrings to all public functions in api.py
> create a README for this project
> generate API documentation from the route handlers
> write a developer setup guidePro Tips
Section titled “Pro Tips”Be Specific About Constraints
Section titled “Be Specific About Constraints”> add caching to the user lookup> use Redis, not in-memory> cache for 5 minutes> invalidate on user updateProvide Examples
Section titled “Provide Examples”> create a new API endpoint similar to /api/users> but for products> use the same patterns and error handlingReference Existing Code
Section titled “Reference Existing Code”> add a new model like the User model in models.py> for storing product reviewsIterate
Section titled “Iterate”Don’t try to do everything in one prompt:
# First, get the basic structure> create a new endpoint for product search
# Then refine> add pagination to the search results
# Then optimize> add caching for common searches