The 7-Step Process

The Context-First Process

The key insight: AI needs massive context BEFORE writing code, unlike human development where the developer already has context in their head.

The Context Pyramid

Your effectiveness with AI depends on how well you build context from the ground up.

                        β–²
                       /β–‘\        1. USER RULES (.cursorrules)
                      /β–‘β–‘β–‘\           (Identity + Guardrails)
                     /β–‘β–‘β–‘β–‘β–‘\
                    /β–“β–“β–“β–“β–“β–“β–“\     2. READ CODEBASE STRUCTURE
                   /β–“β–“β–“β–“β–“β–“β–“β–“β–“\        (Architecture Context)
                  /β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“\
                 /β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’\   3. READ SPECIFIC FILES
                /β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’\      (Implementation Details)
               /β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’\
              /β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ\  4. RESEARCH DOCS + ONLINE
             /β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ\     (External Knowledge)
            /β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ\
           /β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“\  5. WRITE CODE + TESTS
          /β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“\     (Implementation)
         /β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“β–“\
        /β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’\  6. RUN TESTS + COMPILATION
       /β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’\     (Validation Layer)
      /β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’β–’\
     /β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ\  7. LOG β†’ FIX β†’ REPEAT
    /β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ\     (Feedback Loop)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
              IDENTITY β†’ EXECUTION β†’ MASTERY

Each layer builds on the one above. You can't effectively write code (5) without research (4), and you can't research effectively without understanding the codebase (2-3).

The 7 Steps Explained

Load User Rules

Your .cursorrules file (or equivalent) sets the AI's identity and guardrails. This is the foundation everything builds on.

# .cursorrules example
- Use TypeScript strict mode
- Never commit secrets
- Single responsibility principle
- Minimize dependencies
- Test everything

What this does: Gives AI a "senior developer" identity with your coding standards baked in.

Index the Codebase

Let AI understand your project's architecture and structure before diving into specifics.

"Read the project structure. Understand the folder organization,
key dependencies in package.json, and overall architecture."

What this does: AI understands where things live and how they connect.

Read Specific Files

Once AI knows the structure, point it to the exact files relevant to your task.

"Read /src/services/AuthService.ts and /src/utils/validation.ts.
Understand how authentication currently works."

What this does: AI becomes an expert on the specific implementation you're modifying.

Research Docs & Online

Before writing code, have AI research best practices and documentation.

"Research the NextAuth.js documentation for credential providers.
Look up best practices for password hashing in 2024."

What this does: Ensures AI uses current, correct approachesβ€”not outdated patterns.

Write Code + Tests

Nowβ€”and only nowβ€”write implementation code alongside tests.

"Implement the password reset flow. Write the implementation
AND the test file simultaneously. Follow TDD principles."

What this does: Code and tests are born together, ensuring testability.

Run Tests + Compilation

Execute tests and build to validate the implementation.

npm run test
npm run build
npm run lint

What this does: Catches errors before they become commits.

Log β†’ Fix β†’ Repeat

When tests fail, use logs to debug and iterate.

"Here's the test failure output. Read the logs, identify the issue,
fix the code, and we'll run tests again."

What this does: Creates a tight feedback loop until everything passes.

The Development Cycle

The same process as a continuous loop:

                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                 β”‚   1. RULES                          β”‚
                 β”‚   Load .cursorrules / user rules    β”‚
                 β”‚   (Sets identity & guardrails)      β”‚
                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                  β”‚
                                  β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                                                               β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚ 2. INDEX    β”‚ ───► β”‚ 3. READ     β”‚ ───► β”‚ 4. RESEARCH β”‚  β”‚
β”‚   β”‚ Codebase    β”‚      β”‚ Specific    β”‚      β”‚ Docs/Web    β”‚  β”‚
β”‚   β”‚ Structure   β”‚      β”‚ Files       β”‚      β”‚             β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                               β”‚
β”‚                    CONTEXT GATHERING PHASE                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   5. WRITE CODE + TESTS     β”‚
              β”‚   (Implementation)          β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   6. RUN + COMPILE + TEST   β”‚
              β”‚   (Validation)              β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   7. READ LOGS + FIX        │◄────┐
              β”‚   (Debug Loop)              β”‚     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
                            β”‚                     β”‚
                            └──────── ❌ β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                            β”‚
                            βœ“
                            β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚   βœ… COMMIT + SHIP          β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

How This Differs from Traditional TDD

Traditional TDDContext-First ProcessKey Difference
1. Write Test1-4. Build ContextYou front-load understanding
2. Run (Fail)5. Write Code+TestAI-assisted implementation
3. Write Code6. Run TestsSame validation
4. Run (Pass)7. Debug LoopSame iteration
5. Refactorβœ… CommitSame outcome
⚠️

The crucial insight: Traditional TDD assumes the developer already has context in their head. With AI, you must explicitly build that context through steps 1-4 before any code is written.

Why This Works

  1. Guardrails First β€” User rules prevent AI from making common mistakes
  2. Architecture Awareness β€” AI understands how pieces fit together
  3. Implementation Knowledge β€” AI knows the actual code patterns in use
  4. Current Best Practices β€” Research prevents outdated solutions
  5. Test-Driven β€” Code and tests are created together
  6. Validated β€” Nothing ships without passing tests
  7. Iterative β€” Failures become learning opportunities

"The quality of AI output is directly proportional to the quality of context you provide."