Module 02: Core Loop
Last updated:
Time: 45 minutes | Complexity: β Beginner
Previous: Module 01: Installation & Setup
Understand how Claude Code actually works: the decision loop, context, and how to structure requests effectively.
What Youβll Learn
Section titled βWhat Youβll Learnβ- The complete interaction loop (prompt β analysis β decision β action)
- How Claude reads and understands your project
- How context works and why it matters
- Modes: Normal, Plan, and Think modes
- How to structure effective requests
The Complete Loop (Deep Dive)
Section titled βThe Complete Loop (Deep Dive)βEvery interaction with Claude Code follows this sequence:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 1. YOU PROMPT ββ "Fix the bug in auth.js on line 45" βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 2. CLAUDE READS ββ - Reads auth.js (full file) ββ - Reads related files (auth-test.js, config.js, etc) ββ - Understands the error context ββ - Analyzes call sites where auth.js is used βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 3. CLAUDE ANALYZES ββ - Identifies the root cause ββ - Considers side effects ββ - Plans minimal changes ββ - Checks for tests βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 4. CLAUDE DECIDES ββ Does the change need tests? β Suggest test updates ββ Is the change safe? β Proceed or ask for confirmation ββ Should multiple files change? β Show full scope βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 5. CLAUDE PROPOSES ββ Shows you: ββ - Description of changes ββ - diff view (what's changing) ββ - Reasoning βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 6. YOU REVIEW ββ - Read the diff carefully ββ - Ask questions if unclear ββ - Accept or reject the changes βββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ β βΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ 7. CHANGES APPLIED ββ - Files updated on disk ββ - You can now test/run the code ββ - Next iteration begins βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββHow Claude Reads Your Project
Section titled βHow Claude Reads Your ProjectβClaude doesnβt read everything. Itβs intelligent about scope.
Example: You ask βFix the login bugβ
Section titled βExample: You ask βFix the login bugββClaude will:
- Search for βloginβ in your codebase
- Find auth.js, login.js, auth-controller.js
- Read those files first (full content)
- Find callers (what calls these files?)
- Read tests (if they exist)
- Find related config (environment variables, constants)
Claude wonβt read:
- node_modules (excluded automatically)
- .git history (too much data)
- Every file in the project (too slow)
- Your entire codebase unless relevant
Pro Tip
Section titled βPro TipβBe specific about scope:
- β βFix the bugsβ β Claude has to guess which files
- β βFix the login bug in auth.js on line 45β β Claude reads exactly what matters
Context: The Key Concept
Section titled βContext: The Key ConceptβContext is how much of your conversation Claude remembers. Itβs finite (~200K tokens).
What Uses Context?
Section titled βWhat Uses Context?βYour prompt: 50 tokensClaude's response: 500 tokensFile reads: 2000 tokens per filePrevious messages: accumulated tokensThe Context Meter
Section titled βThe Context Meterβ/statusShows:
Context: 67%This means:
- 0-50%: Lots of room remaining, work freely
- 50-70%: Half-used, be mindful
- 70-90%: Getting tight, use
/compact - 90%+: Critical, you must clean up
/compact - Your Safety Valve
Section titled β/compact - Your Safety ValveβWhen context reaches 70%+, use:
/compactThis:
- Summarizes previous conversation
- Discards old messages
- Frees up ~40% context
- Keeps you working in the same session
You can compact multiple times in one session.
Modes: Normal vs Plan vs Think
Section titled βModes: Normal vs Plan vs ThinkβClaude Code has three interaction modes.
Normal Mode (Default)
Section titled βNormal Mode (Default)βClaude makes changes immediately after analyzing. Use for:
- Simple bug fixes
- Small feature additions
- Refactoring small sections
Flow: Ask β Analyze (1-2 sec) β Propose β Apply
Plan Mode (/plan)
Section titled βPlan Mode (/plan)βClaude thinks first, proposes a plan, waits for approval before making changes. Use for:
- Complex features
- Risky changes
- System-wide refactors
- When youβre unsure about approach
Flow: Ask β Think β Propose plan β You approve β Analyze β Apply
Example:
/planRefactor the authentication system to use JWT instead of sessionsClaude responds with a step-by-step plan for you to review.
Think Mode (/think)
Section titled βThink Mode (/think)βClaude shows extended reasoning, thinking through the problem step-by-step. Use for:
- Understanding complex bugs
- Architectural decisions
- Security analysis
- Performance optimization
Flow: Ask β Extended reasoning β Analysis β Proposal
Structuring Effective Requests
Section titled βStructuring Effective RequestsβThe Framework: WHAT, WHERE, HOW, VERIFY
Section titled βThe Framework: WHAT, WHERE, HOW, VERIFYβGood requests follow this pattern:
| Part | Purpose | Example |
|---|---|---|
| WHAT | The goal | βFix the null pointer bugβ |
| WHERE | The scope | βin src/auth/login.js on line 45β |
| HOW | Constraints | βwithout changing the API signatureβ |
| VERIFY | Expected result | βAll existing tests should passβ |
Example Good Request
Section titled βExample Good RequestβFix the bug where login fails for emails with + symbolsWHERE: src/controllers/auth.js, line 78 (email validation regex)HOW: Update the regex to allow + in emails, but keep existing validation otherwiseVERIFY: Existing tests in tests/auth.test.js should passExample Poor Request
Section titled βExample Poor RequestβFix the bugsClaude has to ask follow-up questions instead of solving immediately.
Session Context
Section titled βSession ContextβA session is your current conversation with Claude.
Session Facts
Section titled βSession Factsβ- Starts when you run
claude - Ends when you exit or run
/clear - Not saved by default
- Scoped to one project
- Can be managed with
/rewind(go back N steps)
Checkpoint Sessions
Section titled βCheckpoint SessionsβTo save a session (optional):
/checkpoint save "fixed login, added tests"Later, restore:
/checkpoint load "fixed login, added tests"Exercise: The Complete Loop
Section titled βExercise: The Complete LoopβTask: Create a simple utility function
Section titled βTask: Create a simple utility functionβ- Ask with WHAT/WHERE/HOW/VERIFY:
Create a utility function to validate email addressesWHERE: in src/utils/validators.jsHOW: export as validateEmail(email), return boolean, handle edge casesVERIFY: Write tests in tests/validators.test.js-
Claude analyzes:
- Finds src/utils/
- Reads existing validators
- Checks tests directory structure
- Proposes solution
-
Review the diff:
- Check the function signature
- Check the validation logic
- Review the test cases
-
Accept or iterate:
Looks good, but make the regex more permissive for + symbols -
Claude updates and you review again
-
Done: You have a tested, working function
Key Takeaways
Section titled βKey Takeawaysββ Every request follows: read β analyze β decide β propose β apply
β Be specific (WHAT/WHERE/HOW/VERIFY) for faster results
β Context is finite, watch your percentage and /compact at 70%+
β /plan for risky changes, normal mode for safe ones
β Sessions are temporary, use /checkpoint to save important work
Validation: Youβre Ready Ifβ¦
Section titled βValidation: Youβre Ready Ifβ¦ββ You can explain the 7-step loop to someone else
β You understand what βcontextβ means and why it matters
β You know the difference between Plan and Normal modes
β Youβve used /plan for a complex task
β You can check /status and understand the output
Whatβs Next?
Section titled βWhatβs Next?βModule 03: Memory & Config covers:
- Creating your first CLAUDE.md
- How Claude remembers preferences
- Project vs global settings
- Custom configuration
This will teach you how to make Claude Code remember your style and preferences.
Completed Module 02? β Ready for Module 03: Memory & Config