Advanced Workflows
Patterns for complex projects. Code reviews, refactoring, migrations, and production-grade workflows.
Premium Course Content
This lesson is part of a premium course. Upgrade to Pro to unlock all premium courses and content.
- Access all premium courses
- 1000+ AI skills included
- New content added weekly
Leveling Up
In the previous lesson, we explored bash integration. Now let’s build on that foundation. You know the basics. Now let’s see how to combine them for real-world development.
These workflows represent how professionals actually use Claude Code for serious work.
Workflow: Progressive Refinement
Instead of trying to get perfect code in one shot, build iteratively.
Phase 1: Working Implementation
> Create a function to fetch user data from the API and cache it.
> Focus on making it work. Don't worry about edge cases yet.
Get something functional first.
Phase 2: Add Tests
> Now add tests for this function. Cover:
> - Successful fetch
> - Network error
> - Invalid response
> - Cache hit
Tests before refinement.
Phase 3: Edge Cases
> Now improve the implementation:
> - Handle rate limiting
> - Add retry logic with backoff
> - Handle partial responses
Targeted improvements.
Phase 4: Production Hardening
> Review for production readiness:
> - Proper error messages
> - Logging
> - Type safety
> - Documentation
Final polish.
Why this works: Each phase has a clear goal. You verify at each step. Problems are caught early.
Workflow: Code Review Partner
Use Claude as a code reviewer before opening PRs.
/add $(git diff --name-only main)
> Review these changes as if you were a senior developer.
> Focus on:
> - Logic errors
> - Edge cases that might be missed
> - Performance concerns
> - Security issues
> Flag anything that concerns you.
Claude catches issues before your teammates do.
Follow-up patterns:
> Good catch on the SQL injection risk. Fix it.
> That edge case you mentioned—add a test for it.
> Add error handling for the scenarios you identified.
Workflow: Large-Scale Refactor
Refactoring across many files needs structure.
Step 1: Plan
> We need to convert all callback-based async code to async/await.
> First, scan the codebase and list all files that need changing.
> Group them by complexity (simple, moderate, complex).
Step 2: Create Migration Guide
> Create a markdown file showing before/after examples for our patterns.
> This will be the reference for the refactor.
Step 3: Execute in Chunks
# Session 1
/add src/utils/*.js
> Convert these files to async/await. Follow the migration guide.
# Verify
> Run the tests for these files.
# Session 2
/clear
/add src/services/*.js
> Convert these files to async/await. Same patterns.
# Continue chunk by chunk...
Step 4: Verify Completeness
> Search the codebase for remaining callback patterns.
> List any files we missed.
Workflow: Test-Driven Development
Claude is excellent at TDD when you structure the workflow.
> We're adding a shopping cart total calculator.
> First, write the tests. Consider:
> - Empty cart
> - Single item
> - Multiple items
> - Discounts
> - Tax calculation
> - Currency rounding
> Don't implement yet—just tests.
Review tests. Then:
Quick check: Before moving on, can you recall the key concept we just covered? Try to explain it in your own words before continuing.
> Now implement to make all tests pass.
Then:
> Run the tests. Fix any failures.
Workflow: Understanding Legacy Code
When inheriting unfamiliar code:
Step 1: Overview
/add README.md package.json src/index.js
> Give me a high-level overview of this project.
> What's the tech stack? What's the main purpose?
Step 2: Architecture
/add src/*.js
> Map out the architecture. What are the main modules?
> How do they connect?
Step 3: Deep Dive
/add src/core/*.js
> This seems to be the core logic. Walk me through how it works.
Step 4: Document
> Create a ARCHITECTURE.md documenting what we've discovered.
Workflow: Feature Flag Development
For features that need to be toggleable:
> Implement the new search feature behind a feature flag.
> Requirements:
> - Flag name: NEW_SEARCH_ENABLED
> - Default: false
> - Gradually rollout-able
> - Easy to remove later when fully launched
Then later:
> The feature flag NEW_SEARCH_ENABLED is now 100% rolled out.
> Remove the flag and clean up the old code path.
Workflow: Rubber Duck Debugging
Sometimes you need Claude to think with you, not for you.
> I'm stuck on this authentication bug.
> Let me explain what I think is happening, and you tell me if my logic has gaps.
[Explain your understanding]
> What am I missing? Where could my assumptions be wrong?
Claude often spots the flaw in your reasoning.
Variation: Code Walkthrough
/add src/complex-logic.js
> Walk through this code as if explaining to a junior developer.
> I want to verify I understand it correctly.
Workflow: Production Incident Response
When something breaks:
> We have a production issue. Users are seeing 500 errors on checkout.
> Help me investigate. Here's what we know:
> [Paste error logs]
/add src/checkout/*.js
> What could cause this error?
Then:
> Let's test hypothesis 1: database connection issue.
> What commands should I run to verify?
> That checks out. Now hypothesis 2: race condition in inventory check.
> Walk me through how this could happen.
Systematic debugging with AI assistance.
Workflow: Cross-Codebase Changes
For changes that span multiple repositories:
# In API repo
> We're adding a new field "phoneNumber" to the User response.
> Update the API to include this.
# In frontend repo (new session)
/clear
> The API now returns "phoneNumber" in the User object.
> Update the frontend to display it in the profile page.
# In mobile repo (new session)
/clear
> The API now returns "phoneNumber" in the User object.
> Update the mobile app to handle it.
Claude doesn’t share context between sessions, but you can describe the cross-repo change in each.
Key Takeaways
- Progressive refinement: working → tested → hardened
- Use Claude as a code reviewer before PRs
- Structure large refactors: plan → chunk → verify → repeat
- TDD workflow: tests first, then implement
- Rubber duck with Claude to find logic gaps
- Match your workflow complexity to task complexity
Final lesson: put everything together in a capstone project.
Up next: In the next lesson, we’ll dive into Capstone: Build a Complete Feature.
Knowledge Check
Complete the quiz above first
Lesson completed!