Back to Home
    AI WorkflowAI Workflow 2024Beginner

    AI Workflow

    AI workflow cheat sheet for building software with AI — planning, incremental development, testing strategies, and codebase management tips.

    15 min read
    aiworkflowdevelopmentplanningtestinggitbest-practices

    Quick Start Summary

    2 topics

    The Core Workflow

    Essential steps for AI-assisted development

    WORKFLOW OVERVIEW:
    
    1. Plan first - Create PLAN.md and claude.md before writing any code
    2. Manual foundation - Set up your project boilerplate yourself, not with AI
    3. Incremental development - For each feature:
       - Break it down into small steps
       - Implement one step at a time with AI
       - Test it manually
       - Review and edit the code yourself
       - Write tests (when appropriate)
       - Commit
    4. Never skip manual review - You're responsible for understanding every line
    5. Commit frequently - After every working step, not at the end of the day

    💡 Planning saves time and produces better results

    ⚡ Small steps make debugging easier when things break

    📌 Manual review is where your expertise matters most

    🎯 Frequent commits create safe rollback points

    workflowoverview

    Typical Time Investment

    Expected time commitment for each phase

    TIME BREAKDOWN:
    
    Planning Phase (one-time per project):
    - PLAN.md creation: 30-90 minutes
    - Context setup: 15-30 minutes
    
    Foundation Phase (one-time):
    - Manual boilerplate: 15-30 minutes
    
    Development Loop (per feature):
    - Breaking down feature: 5-10 minutes
    - Each implementation step: 10-30 minutes
    - Code review per step: 5-10 minutes
    - Testing per feature: 15-30 minutes
    - Feature completion: 15-30 minutes
    
    Total per feature: 2-4 hours including all steps

    💡 Front-loading planning pays dividends throughout development

    ⚡ Small steps (10-30 min) keep you focused and productive

    📌 Manual review time is non-negotiable for quality

    🎯 These timeframes assume AI assistance — would be 2-3x longer manually

    planningtime-management

    Planning & Context Setup

    2 topics

    Create Your PLAN.md

    Document project goals, features, and technical decisions

    markdown
    PLAN.MD STRUCTURE:
    
    # Project: [Your Project Name]
    
    ## Goals
    - Primary objective
    - Secondary objectives
    - Success criteria
    
    ## Tech Stack
    - Framework: [chosen framework and version]
    - Database: [database choice]
    - Authentication: [auth solution]
    - Styling: [CSS framework/solution]
    - Deployment: [hosting platform]
    
    ## Features
    1. Feature Name
       - Step 1: [specific, testable step]
       - Step 2: [specific, testable step]
       - Step 3: [specific, testable step]
    
    2. Next Feature
       - Step 1: ...
    
    ## Technical Constraints
    - Performance requirements
    - Budget limitations
    - Browser/device support
    
    ## Open Questions
    - Decisions still to be made
    - Areas needing research

    💡 Break features into specific, testable steps from the start

    ⚡ This is a living document — update as you learn

    📌 Clear goals prevent scope creep and wasted effort

    🎯 Tech stack decisions upfront avoid costly rewrites

    planningdocumentation

    Create Context Files

    Provide AI with project-specific guidelines and references

    markdown
    CONTEXT FILE STRUCTURE:
    
    Small Projects (< 20 files):
    - Single claude.md file with everything
    
    Large Projects:
    - .claude/ai-interaction.md     — Communication preferences
    - .claude/development-workflow.md — Team standards
    - .claude/coding-standards.md   — Code style and patterns
    - .claude/project-plan.md       — Current roadmap
    - .claude/current-sprint.md     — Active work
    
    CLAUDE.MD TEMPLATE:
    
    # AI Context for [Project Name]
    
    ## Project Structure
    - /app        — Main application code
    - /components — Reusable components
    - /lib        — Utility functions
    
    ## Coding Standards
    - Use TypeScript strict mode — no 'any' types
    - Prefer server components unless interactivity needed
    - Keep components under 200 lines
    
    ## Preferences
    - Explicit over clever — readable code wins
    - Always include error handling
    - Descriptive variable names, not abbreviations
    
    ## What NOT to do
    - Don't use client components unless necessary
    - Don't install packages without asking
    - Don't skip error handling

    💡 Context files guide AI to match your style and preferences

    ⚡ Include links to docs — AI can fetch and apply them

    📌 'What NOT to do' section prevents common mistakes

    🎯 Update context when you make architectural decisions

    contextdocumentationai-setup

    Manual Foundation

    1 topic

    Manual Boilerplate Setup

    Why and how to set up your project foundation manually

    bash
    # MANUAL SETUP STEPS:
    
    # 1. Run framework initialization
    npx create-next-app@latest
    npm create vite@latest
    rails new app_name
    django-admin startproject
    
    # 2. Install core dependencies manually
    npm install prisma @prisma/client
    # Add essential packages you know you need
    
    # 3. Configure tools
    # TypeScript/ESLint configuration
    # Environment variables (.env.example)
    
    # 4. Initial commit
    git init
    git add .
    git commit -m 'Initial project setup'
    
    # WHY MANUAL?
    # You need to understand your foundation.
    # AI should build on solid ground that you control.
    # If something breaks, you need to know how it was set up.

    💡 Manual setup gives you deep understanding of your foundation

    ⚡ Framework CLIs are designed for this — use them directly

    📌 Mystery foundations lead to mystery bugs later

    🎯 This one-time investment pays off throughout the project

    setupboilerplatefoundation

    AI-Assisted Development Loop

    6 topics

    Break Down Features

    Decompose features into small, achievable steps

    FEATURE BREAKDOWN PROCESS:
    
    1. Select next feature from PLAN.md
    2. Have AI read context files (claude.md, PLAN.md)
    3. Ask AI to break down into specific steps
    4. Review proposed steps carefully
    5. Adjust or reorder as needed
    6. Get alignment before proceeding
    
    EXAMPLE PROMPT:
    "Read PLAN.md and claude.md. For the 'User Authentication' feature,
    break down the implementation into specific, testable steps.
    Each step should be small enough to implement and test in under 30 minutes."
    
    GOOD STEPS:
    ✅ Step 1: Install and configure NextAuth with credentials provider
    ✅ Step 2: Create user model in Prisma schema
    ✅ Step 3: Build signup form component and server action
    ✅ Step 4: Build login form component and server action
    ✅ Step 5: Add protected route middleware
    
    BAD STEPS:
    ❌ Step 1: Build the entire authentication system (too big)
    ❌ Step 1: Add one line to the config file (too small)

    💡 Steps should take 20-30 minutes to implement and test

    ⚡ Small steps make debugging infinitely easier

    📌 Review AI-proposed steps — it might miss important details

    🎯 Good breakdown is 70% of successful implementation

    planningfeature-development

    Implement One Step

    Work on a single step with clear, detailed instructions

    IMPLEMENTATION PROCESS:
    
    1. Give AI ONE specific step
    2. Provide clear, detailed instructions
    3. Let AI create/modify necessary files
    4. Do NOT move to next step yet
    
    EXAMPLE PROMPT:
    "Implement Step 1: Install and configure NextAuth with credentials provider.
    
    Tasks:
    - Install next-auth package
    - Create app/api/auth/[...nextauth]/route.ts
    - Set up basic configuration with credentials provider
    - Add required environment variables to .env.example
    
    Follow the patterns in claude.md and use NextAuth v5."
    
    BETTER PROMPTING TIPS:
    - Reference specific files: "Add this to lib/auth.ts"
    - Specify packages: "Use next-auth v5, not v4"
    - Call out edge cases: "Handle the case where email already exists"
    - Be explicit: "Use bcrypt for password hashing, 10 rounds"

    💡 Specificity in prompts leads to better code quality

    ⚡ Reference context files to maintain consistency

    📌 One step at a time prevents cascading failures

    🎯 Clear constraints guide AI to better solutions

    implementationprompting

    Test & Verify

    Manually test each implementation step

    TESTING CHECKLIST:
    
    Run the application:
    - npm run dev / rails server / etc.
    - Check browser console for errors
    - Check terminal for warnings
    
    Verify functionality:
    ✅ Does it work in the happy path?
    ✅ Does it handle errors gracefully?
    ✅ Are there any console warnings?
    ✅ Does it work on mobile viewport?
    ✅ Is the UI accessible (keyboard navigation)?
    
    Test edge cases:
    - What happens with bad input?
    - What happens with empty input?
    - What happens when services fail?
    - What happens with slow connections?
    
    If broken:
    - Have AI fix it before proceeding
    - Don't accumulate broken code

    💡 Manual testing catches issues AI testing might miss

    ⚡ Test immediately while the context is fresh

    📌 Edge case testing prevents production surprises

    🎯 Fix issues now — they compound if left alone

    testingquality-assurance

    Manual Code Review

    Review and improve AI-generated code

    CODE REVIEW CHECKLIST:
    
    Open modified files and ask:
    - Does this match my coding style?
    - Are there security concerns?
    - Could this be more performant?
    - Is error handling adequate?
    - Would I understand this in 6 months?
    
    COMMON CHECKS:
    
    Security:
    - Are user inputs validated?
    - SQL injection risks?
    - XSS vulnerabilities?
    
    Error Handling:
    - What happens when things fail?
    - Are errors logged appropriately?
    
    Performance:
    - Unnecessary database queries?
    - N+1 query problems?
    
    Type Safety:
    - Are types specific enough?
    - Any 'any' types sneaking in?
    
    WHY THIS MATTERS:
    AI gets you 80-90% there, but that last 10-20% needs a human touch.
    You're the senior developer reviewing a junior's code.

    💡 This step separates quality code from technical debt

    ⚡ Make manual edits — don't just accept AI output

    📌 Security and performance need human judgment

    🎯 Your expertise matters most during review

    code-reviewquality

    Write Tests (When Appropriate)

    Add test coverage for features that need it

    TESTING STRATEGY:
    
    When to write tests:
    ✅ Business logic functions
    ✅ API endpoints or server actions
    ✅ Database queries and transformations
    ✅ Authentication/authorization logic
    ✅ Complex algorithms or calculations
    ✅ Utility functions used across codebase
    
    When to skip tests:
    ⏭️ Simple configuration files
    ⏭️ Basic UI components (mostly markup)
    ⏭️ One-off scripts or migrations
    ⏭️ Prototype/spike code you'll throw away
    
    TEST TYPES:
    
    Unit Tests — Individual functions in isolation
    - Good for: utility functions, business logic
    - Fast, focused, easy to maintain
    
    Integration Tests — How parts work together
    - Good for: API routes, server actions, database operations
    - Most valuable for typical web apps
    
    End-to-End Tests — Complete user flows
    - Good for: critical user journeys only
    - Slow but catch real-world issues

    💡 Not every step needs tests, but every feature should have appropriate coverage

    ⚡ AI can generate test scaffolding — you verify quality

    📌 Integration tests provide best ROI for most projects

    🎯 Tests are your safety net as the codebase grows

    testingquality-assurance

    Commit Your Work

    Create checkpoints with meaningful commits

    bash
    # COMMIT WORKFLOW
    # Once step works AND tests pass:
    git add .
    git commit -m 'feat: implement NextAuth credentials provider'
    
    # COMMIT MESSAGE FORMAT (Conventional Commits):
    # feat:     add user authentication
    # fix:      resolve login redirect issue
    # test:     add unit tests for auth flow
    # refactor: simplify error handling
    # docs:     update README with setup instructions
    # chore:    update dependencies
    
    # When to commit:
    # ✅ After each implementation step (if it works)
    # ✅ After fixing a bug
    # ✅ Before switching to a different feature
    
    # When NOT to commit:
    # ❌ When code doesn't run
    # ❌ When tests are failing
    
    # Save in-progress work without committing:
    git stash save 'WIP: halfway through login form'
    # Work on something else...
    git stash pop  # Come back to it later

    💡 Small, focused commits make debugging and rollback easy

    ⚡ Commit after every working step — creates safe checkpoints

    📌 Good commit messages are documentation for your future self

    🎯 Aim for 5-10 commits per day of active development

    gitversion-control

    Key Principles

    1 topic

    Fundamental Principles

    The non-negotiable rules for quality AI-assisted development

    10 KEY PRINCIPLES:
    
    1. NEVER SKIP PLANNING
       AI amplifies your plan. Vague plans produce vague results.
    
    2. ALWAYS SET UP FOUNDATION MANUALLY
       You must understand the base of your application.
       Don't let AI create mystery infrastructure.
    
    3. ONE STEP AT A TIME
       Small, incremental steps lead to better code and easier debugging.
       If something breaks, you know exactly what changed.
    
    4. TEST BEFORE COMMITTING
       Every commit should represent a working state.
    
    5. COMMIT FREQUENTLY
       Aim for 5-10 commits per day.
       Small commits = easy rollback + understandable history.
    
    6. ALWAYS REVIEW AI CODE
       You are responsible. AI is your junior developer.
    
    7. WRITE REAL TESTS
       Tests are not optional. They're your safety net.
    
    8. KEEP CONTEXT UPDATED
       Update context files when you make architectural decisions.
    
    9. MANUAL EDITING IS EXPECTED
       Good developers: 60% AI-generated, 40% manually refined
       Poor developers: 100% copy-paste without understanding
    
    10. STAY IN CONTROL
        You are the lead developer. AI is your assistant.
        Red flag: 'I don't understand what the AI built, but it works!'

    💡 These principles prevent technical debt accumulation

    ⚡ Following them makes you faster long-term, not slower

    📌 Quality code with AI requires MORE discipline, not less

    🎯 You own every line of code in your project

    principlesbest-practices

    Common Pitfalls to Avoid

    3 topics

    Planning & Setup Mistakes

    Errors made before coding begins

    PITFALL: Starting Without A Plan
    The mistake: Opening AI tool and starting with vague ideas
    Why it fails: AI needs direction — inconsistent results, wasted time
    The fix: Spend 30-60 minutes writing solid PLAN.md before code
    
    PITFALL: Skipping Manual Setup
    The mistake: Asking AI to 'create a Next.js app with all the boilerplate'
    Why it fails: You don't understand your foundation
    The fix: Always run framework CLI yourself (create-next-app, etc)
    
    PITFALL: Letting Context Get Stale
    The mistake: Writing plan on day 1, never updating as things change
    Why it fails: AI gives bad suggestions based on outdated information
    The fix: Update PLAN.md and claude.md with architectural decisions

    ❌ AI without planning is like building without blueprints

    ❌ Mystery foundations lead to mystery bugs

    ❌ Stale context wastes time with wrong suggestions

    ✅ Front-load planning — it pays dividends throughout

    pitfallsplanning

    Implementation Mistakes

    Errors during the development process

    PITFALL: Implementing Multiple Steps At Once
    The mistake: 'Build entire authentication with login, signup, reset, email verification'
    Why it fails: Too much code at once — when it breaks, you don't know why
    The fix: Break it down. One feature at a time. One step at a time.
    
    PITFALL: Trusting AI Output Blindly
    The mistake: Copy-pasting AI code without reading or understanding
    Why it fails: Building on foundation you don't understand — technical debt compounds
    The fix: Read every line. Understand what it does. Edit what needs editing.
    
    PITFALL: Rushing Through Steps
    The mistake: Skipping manual review to 'move faster'
    Why it fails: You ship bugs, accumulate debt, slow down over time
    The fix: Manual review IS the speed. Quality code moves faster long-term.

    ❌ Large steps → hard debugging → wasted time

    ❌ Blind trust → technical debt → maintenance nightmares

    ❌ Code you don't understand is a ticking time bomb

    ✅ Slow down to speed up — quality compounds

    pitfallsimplementation

    Testing & Quality Mistakes

    Shortcuts that hurt long-term quality

    PITFALL: Not Testing Before Committing
    The mistake: Committing code because 'it looks right' without running it
    Why it fails: Accumulating broken commits — git history becomes unreliable
    The fix: Always run the app. Test the feature. Then commit.
    
    PITFALL: Skipping Tests
    The mistake: 'I'll add tests later when I have time'
    Why it fails: Later never comes. As codebase grows, afraid to change anything.
    The fix: Write tests as you build features. Make it part of workflow.
    
    PITFALL: Not Committing Frequently Enough
    The mistake: Working for 4 hours, building 3 features, one giant commit
    Why it fails: Can't easily roll back — git history is useless
    The fix: Commit after every working step. Small commits = easy rollbacks.

    ❌ Untested commits break build history

    ❌ No tests → fear of changes → stagnant codebase

    ❌ Giant commits → impossible to debug or rollback

    ✅ Test, commit, repeat — creates safety net

    pitfallstestinggit

    Troubleshooting Common Issues

    3 topics

    AI Keeps Breaking Things

    Every change breaks something else

    PROBLEM:
    Every time you ask for a change, something else breaks.
    
    DIAGNOSIS:
    Your steps are too big. AI is changing too many things at once.
    
    SOLUTION:
    - Break requests into smaller steps
    - One file at a time
    - One feature at a time
    - Verify each step before proceeding

    💡 Smaller steps = fewer variables when debugging

    ⚡ Request changes to specific files, not broad features

    📌 Verify each change works before asking for next

    🎯 'Change just the auth logic in this file'

    troubleshooting

    AI Not Following Context

    AI keeps using patterns you said not to use

    PROBLEM:
    AI keeps using patterns you explicitly said not to use.
    
    DIAGNOSIS:
    Your context file isn't clear enough, or AI isn't reading it.
    
    SOLUTION:
    - Make context more explicit: 'NEVER use X, ALWAYS use Y'
    - Explicitly tell AI to read: 'Read claude.md and follow coding standards'
    - Put most important rules at the top
    - Use examples: 'Good: [example]  Bad: [example]'
    - Reference context file in every major prompt

    💡 AI responds better to explicit 'NEVER' and 'ALWAYS'

    ⚡ Provide examples of what you want and don't want

    📌 Reference context file in every major prompt

    🎯 'Read claude.md' ensures AI loads your preferences

    troubleshootingcontext

    Don't Understand AI's Code

    Looking at generated code and confused

    PROBLEM:
    Looking at AI-generated code and you're confused.
    
    DIAGNOSIS:
    You skipped manual review, or AI's solution is overcomplicated.
    
    SOLUTION:
    - Stop. Don't move forward.
    - Ask AI to explain what it did
    - If too complex, ask for simpler solution
    - Rewrite parts you don't understand in your own style
    
    EXAMPLE PROMPT:
    "I don't understand this code you generated in lib/auth.ts:
    [paste confusing section]
    
    Can you explain:
    1. What this code does
    2. Why it's necessary
    3. What would happen if we removed it
    4. If there's a simpler way to achieve the same thing"

    💡 Never proceed with code you don't understand

    ⚡ Ask AI to explain — it's good at that

    📌 Request simpler solutions if explanation is still unclear

    🎯 Understanding the code is not optional

    troubleshootingcode-review

    Related Articles

    Background reading and deeper explanations for this sheet.

    AI Product Pricing Strategies: How to Monetize for Growth, Margin, and Customer Trust

    Pricing an AI product is not just a finance decision—it shapes adoption, retention, margins, and user trust. In this practical guide, you’ll learn how to choose the right pricing model, align price with value and costs, and avoid common mistakes using real-world examples and implementation frameworks.

    keyword overlap

    Intro to FastAPI: Build a Production-Ready Python API with Real Examples

    FastAPI is one of the fastest ways to build modern APIs in Python without sacrificing code quality or developer experience. In this practical, beginner-friendly guide, you’ll learn how to create endpoints, validate data, handle errors, connect a database, secure routes, and prepare your FastAPI app for real-world deployment.

    keyword overlap

    Scaling AI APIs with FastAPI, Docker, and Load Balancers: A Practical Guide for Production

    Building an AI API is easy—keeping it fast and reliable under real traffic is the hard part. In this practical guide, you’ll learn how to scale FastAPI services with Docker and load balancers, from local setup to production architecture, with real-world examples, code, and deployment tips.

    keyword overlap

    Building Autonomous Agents Without Overengineering: A Practical Guide for Real-World Teams

    Autonomous agents can automate meaningful work, but many projects fail because teams overbuild too early. This practical guide shows you how to design, ship, and improve useful agents with simple patterns, clear guardrails, and real-world examples—without turning your stack into a science project.

    keyword overlap