<metadata>
purpose: Deep dive into Core Four In-Agent Leverage Points (1-4)
type: technical-reference
domain: agentic-coding
category: in-agent-leverage
audience: LLM-optimized
last-updated: 2025-09-30
</metadata>

<overview>
The Core Four In-Agent Leverage Points represent direct control mechanisms within the agent's operational environment. These are the highest-leverage, most immediate interventions available to developers in Phase 2 SDLC. Mastery of these four points is prerequisite for effective agentic coding.
</overview>

<leverage-point-1>
<name>CONTEXT: What can your agent see?</name>
<priority>critical</priority>
<impact-rating>10/10</impact-rating>

<definition>
Context encompasses all information available to the agent during task execution: conversation history, files read, documentation provided, environment details, and prior decisions. Agent performance is directly proportional to context quality and relevance.
</definition>

<agent-limitations>
  <limitation>Agents cannot see files unless explicitly shown via Read tool</limitation>
  <limitation>Conversation history has token limits (context window)</limitation>
  <limitation>No persistent memory across sessions without explicit storage</limitation>
  <limitation>Cannot infer project structure without exploration</limitation>
</agent-limitations>

<optimization-strategies>
  <strategy name="Proactive Context Loading">
    <description>Provide relevant files before agent requests them</description>
    <example>
      Bad:  "Fix the authentication bug"
      Good: "Fix the authentication bug. Here's auth.js, user.model.js, and the error logs."
    </example>
    <impact>Reduces back-and-forth by 70%</impact>
  </strategy>

  <strategy name="Layered Context Hydration">
    <description>Start broad, then narrow focus based on task</description>
    <layers>
      <layer1>Project overview (README, architecture)</layer1>
      <layer2>Relevant subsystem (module docs, related files)</layer2>
      <layer3>Specific implementation (exact file, function, tests)</layer3>
    </layers>
    <example>
      "We're building an e-commerce platform [layer 1].
       The checkout system handles payments via Stripe [layer 2].
       The bug is in checkout/payment.ts line 47 where token validation fails [layer 3]."
    </example>
  </strategy>

  <strategy name="Context Persistence">
    <description>Use ken-you-remember (store_fr3k) to preserve decisions across sessions</description>
    <pattern>
      1. Make important decision
      2. store_fr3k: "Decided to use Redis for session storage due to scale requirements"
      3. Later session: recall_fr3k retrieves this context automatically
    </pattern>
    <impact>Eliminates re-explaining architecture every conversation</impact>
  </strategy>

  <strategy name="Targeted Context Injection">
    <description>UFC system for domain-specific knowledge</description>
    <structure>
      ~/.claude/context/
        ├── tools/             # Tool capabilities
        ├── patterns/          # Coding patterns
        ├── architecture/      # System design
        └── domain/            # Business logic
    </structure>
    <usage>Agent loads only relevant context files per task</usage>
  </strategy>

  <strategy name="Context Compression">
    <description>Maximize information density within token limits</description>
    <techniques>
      <technique>XML tags for structure (LLMs parse efficiently)</technique>
      <technique>Code snippets over full files when possible</technique>
      <technique>Summaries with "see file X for details" pointers</technique>
      <technique>Remove boilerplate/comments in context sharing</technique>
    </techniques>
  </strategy>
</optimization-strategies>

<context-antipatterns>
  <antipattern name="Context Dumping">
    <description>Providing every file in codebase</description>
    <consequence>Overwhelms context window, dilutes signal</consequence>
    <fix>Curate relevant subset only</fix>
  </antipattern>

  <antipattern name="Assumed Context">
    <description>"You should know this from earlier"</description>
    <consequence>Agent has no memory unless explicitly provided</consequence>
    <fix>Always re-establish context or use recall_fr3k</fix>
  </antipattern>

  <antipattern name="Vague Context">
    <description>"The user authentication stuff"</description>
    <consequence>Agent must guess which files/logic</consequence>
    <fix>Specific file paths and function names</fix>
  </antipattern>
</context-antipatterns>

<measurement>
  <metric>Context Hit Rate: % of needed info provided upfront</metric>
  <metric>Context Waste: % of provided info not used in solution</metric>
  <metric>Clarification Rounds: # of back-and-forth exchanges</metric>
  <target>90%+ hit rate, <10% waste, <2 clarifications</target>
</measurement>
</leverage-point-1>

<leverage-point-2>
<name>MODEL: Which LLM powers your agent?</name>
<priority>high</priority>
<impact-rating>8/10</impact-rating>

<definition>
The underlying Large Language Model determines reasoning capability, token limits, tool use proficiency, and task-specific strengths. Model selection is not one-size-fits-all; optimal choice depends on task complexity, cost constraints, and latency requirements.
</definition>

<model-comparison>
  <model name="Claude Sonnet 4.5">
    <strengths>
      <strength>Superior reasoning for complex architecture decisions</strength>
      <strength>Best-in-class tool use (file operations, shell commands)</strength>
      <strength>Large context window (200K tokens)</strength>
      <strength>Excellent code generation quality</strength>
    </strengths>
    <weaknesses>
      <weakness>Higher cost per token</weakness>
      <weakness>Slightly slower response time</weakness>
    </weaknesses>
    <use-cases>
      <use-case>Complex refactoring requiring deep codebase understanding</use-case>
      <use-case>Architectural decisions with multiple tradeoffs</use-case>
      <use-case>Tasks requiring extensive file operations</use-case>
    </use-cases>
  </model>

  <model name="GPT-4 Turbo">
    <strengths>
      <strength>Fast response times</strength>
      <strength>Good general-purpose coding</strength>
      <strength>Strong API/library knowledge</strength>
    </strengths>
    <weaknesses>
      <weakness>128K token limit (half of Claude)</weakness>
      <weakness>Less sophisticated tool use</weakness>
    </weaknesses>
    <use-cases>
      <use-case>Quick bug fixes and simple features</use-case>
      <use-case>API integration tasks</use-case>
      <use-case>Documentation generation</use-case>
    </use-cases>
  </model>

  <model name="GPT-4o">
    <strengths>
      <strength>Fastest response times</strength>
      <strength>Lower cost</strength>
      <strength>Good for iterative tasks</strength>
    </strengths>
    <weaknesses>
      <weakness>Less reasoning depth</weakness>
      <weakness>More prone to hallucination</weakness>
    </weaknesses>
    <use-cases>
      <use-case>Repetitive code generation (CRUD, boilerplate)</use-case>
      <use-case>Simple test writing</use-case>
      <use-case>Code formatting/linting</use-case>
    </use-cases>
  </model>

  <model name="Gemini 1.5 Pro">
    <strengths>
      <strength>2M token context window (10x Claude)</strength>
      <strength>Excellent for document-heavy tasks</strength>
    </strengths>
    <weaknesses>
      <weakness>Less mature tool ecosystem</weakness>
      <weakness>Variable reasoning quality</weakness>
    </weaknesses>
    <use-cases>
      <use-case>Analyzing large codebases or documentation sets</use-case>
      <use-case>Migration tasks requiring full codebase context</use-case>
    </use-cases>
  </model>
</model-comparison>

<optimization-strategies>
  <strategy name="Task-Model Matching">
    <description>Select model based on task complexity</description>
    <decision-tree>
      <branch>
        <condition>Complex reasoning required?</condition>
        <yes>Claude Sonnet 4.5</yes>
        <no>Continue...</no>
      </branch>
      <branch>
        <condition>Need massive context?</condition>
        <yes>Gemini 1.5 Pro</yes>
        <no>Continue...</no>
      </branch>
      <branch>
        <condition>Speed critical?</condition>
        <yes>GPT-4o</yes>
        <no>GPT-4 Turbo (balanced)</no>
      </branch>
    </decision-tree>
  </strategy>

  <strategy name="Model Cascading">
    <description>Use cheaper models first, escalate if needed</description>
    <pattern>
      1. GPT-4o attempts simple implementation
      2. If output quality insufficient, escalate to GPT-4 Turbo
      3. If still insufficient, escalate to Claude Sonnet 4.5
    </pattern>
    <benefit>Optimizes cost while maintaining quality floor</benefit>
  </strategy>

  <strategy name="Specialized Model Routing">
    <description>Different models for different task types</description>
    <routing>
      <route task="Architecture/Design" model="Claude Sonnet 4.5"/>
      <route task="Implementation" model="GPT-4 Turbo"/>
      <route task="Testing" model="GPT-4o"/>
      <route task="Documentation" model="GPT-4 Turbo"/>
      <route task="Debugging" model="Claude Sonnet 4.5"/>
    </routing>
  </strategy>
</optimization-strategies>

<model-limitations>
  <limitation>All models hallucinate - validation required regardless</limitation>
  <limitation>Context window limits are hard constraints</limitation>
  <limitation>Model knowledge cutoff dates vary (affects recent APIs/libraries)</limitation>
  <limitation>Tool use capability varies dramatically between models</limitation>
</model-limitations>
</leverage-point-2>

<leverage-point-3>
<name>PROMPT: How are you communicating?</name>
<priority>critical</priority>
<impact-rating>10/10</impact-rating>

<definition>
The prompt is your communication interface with the agent. Quality of prompt directly determines quality of output. Effective prompts provide clear intent, constraints, examples, and success criteria. Poor prompts generate irrelevant, incomplete, or hallucinated responses.
</definition>

<prompt-anatomy>
  <component name="Intent">
    <description>What you want the agent to do</description>
    <example>
      Bad:  "Fix the auth"
      Good: "Modify the authentication middleware to add JWT token refresh logic"
    </example>
  </component>

  <component name="Constraints">
    <description>Boundaries and requirements</description>
    <example>
      "Must maintain backward compatibility with existing tokens.
       Must not modify user.model.js.
       Must add tests for refresh flow."
    </example>
  </component>

  <component name="Context">
    <description>Background information</description>
    <example>
      "Current implementation uses 15-minute access tokens.
       Users are being logged out too frequently.
       We want to add 7-day refresh tokens."
    </example>
  </component>

  <component name="Examples">
    <description>Show desired output format</description>
    <example>
      "Similar to how password reset tokens work in auth/reset.ts:
       - Store refresh token in database with expiry
       - Validate on refresh endpoint
       - Rotate token after use"
    </example>
  </component>

  <component name="Success Criteria">
    <description>How to know task is complete</description>
    <example>
      "Success means:
       1. Refresh token endpoint returns new access token
       2. Expired refresh tokens are rejected
       3. All auth tests pass
       4. Manual testing shows users stay logged in for 7 days"
    </example>
  </component>
</prompt-anatomy>

<optimization-strategies>
  <strategy name="Imperative Clarity">
    <description>Use direct commands, not questions</description>
    <comparison>
      <weak>Could you maybe look at fixing the authentication issue?</weak>
      <strong>Fix the JWT token expiration bug in auth/middleware.ts</strong>
    </comparison>
  </strategy>

  <strategy name="Constrained Generation">
    <description>Explicit boundaries prevent scope creep</description>
    <pattern>
      "ONLY modify auth/middleware.ts.
       DO NOT change database schema.
       DO NOT refactor existing functions.
       ADD new refresh logic only."
    </pattern>
    <benefit>Prevents agent from over-engineering</benefit>
  </strategy>

  <strategy name="Structured Output Requests">
    <description>Specify desired format</description>
    <example>
      "Provide your solution in this format:
       1. Code changes (with file paths)
       2. Test additions
       3. Migration steps (if any)
       4. Breaking changes (if any)"
    </example>
  </strategy>

  <strategy name="Few-Shot Prompting">
    <description>Show 2-3 examples of desired behavior</description>
    <pattern>
      "Write error handling similar to these examples:

       Example 1 (validation):
       if (!userId) throw new ValidationError('userId required')

       Example 2 (not found):
       if (!user) throw new NotFoundError('User not found')

       Example 3 (auth):
       if (!token) throw new UnauthorizedError('Token missing')"
    </pattern>
  </strategy>

  <strategy name="Chain-of-Thought Elicitation">
    <description>Request reasoning before output</description>
    <prompt>
      "Before implementing, explain:
       1. Your understanding of the requirement
       2. Your proposed approach
       3. Potential edge cases
       Then implement the solution."
    </prompt>
    <benefit>Catches misunderstandings early</benefit>
  </strategy>
</optimization-strategies>

<prompt-antipatterns>
  <antipattern name="Vague Directives">
    <example>"Make it better"</example>
    <consequence>Agent guesses at intent, likely misses target</consequence>
    <fix>Specific, measurable improvement criteria</fix>
  </antipattern>

  <antipattern name="Assumed Knowledge">
    <example>"Use the standard pattern"</example>
    <consequence>Agent's "standard" may differ from yours</consequence>
    <fix>Explicitly reference or show the pattern</fix>
  </antipattern>

  <antipattern name="Multi-Intent Confusion">
    <example>"Fix auth and also refactor database and add tests"</example>
    <consequence>Agent prioritizes poorly or does partial work</consequence>
    <fix>One clear primary intent per prompt, secondary tasks listed explicitly</fix>
  </antipattern>

  <antipattern name="Politeness Overhead">
    <example>"If you don't mind, could you possibly..."</example>
    <consequence>Wastes tokens, no benefit</consequence>
    <fix>Direct imperatives: "Implement...", "Fix...", "Add..."</fix>
  </antipattern>
</prompt-antipatterns>

<advanced-techniques>
  <technique name="System Prompts">
    <description>Persistent instructions across conversation (CLAUDE.md, UFC)</description>
    <example>
      "For this project:
       - Always use TypeScript strict mode
       - Write tests using Vitest
       - Follow DDD architecture patterns
       - Store decisions in ken-you-remember"
    </example>
  </technique>

  <technique name="Meta-Prompting">
    <description>Have agent generate its own task breakdown</description>
    <pattern>
      "Create a TodoWrite list for implementing this feature, then execute each step."
    </pattern>
  </technique>

  <technique name="Critique-Revise Loop">
    <description>Agent generates, then critiques its own output</description>
    <pattern>
      "Generate solution. Then critique it for edge cases, security issues, and performance. Revise based on critique."
    </pattern>
  </technique>
</advanced-techniques>
</leverage-point-3>

<leverage-point-4>
<name>TOOLS: What can your agent execute?</name>
<priority>high</priority>
<impact-rating>9/10</impact-rating>

<definition>
Tools are executable capabilities available to the agent: file operations (Read/Write/Edit), shell commands (Bash), search (Grep/Glob), web access (WebFetch/WebSearch), task management (TodoWrite), and memory (ken-you-remember). Tool proficiency is the difference between theoretical agents and practical agents.
</definition>

<core-tools>
  <tool name="Read">
    <purpose>View file contents</purpose>
    <criticality>Essential - agents must see code to modify it</criticality>
    <best-practice>Always read before editing, even if "agent should know"</best-practice>
    <parameters>
      <param>file_path: Absolute path required</param>
      <param>offset: Starting line (optional)</param>
      <param>limit: Number of lines (optional)</param>
    </parameters>
  </tool>

  <tool name="Write">
    <purpose>Create new file or overwrite existing</purpose>
    <criticality>High - but prefer Edit for existing files</criticality>
    <best-practice>Must Read file first if it exists (enforced)</best-practice>
    <danger>Overwrites entire file, no undo</danger>
  </tool>

  <tool name="Edit">
    <purpose>Surgical modification of existing files</purpose>
    <criticality>Essential - safer than Write for changes</criticality>
    <best-practice>Use exact string matching, include context for uniqueness</best-practice>
    <parameters>
      <param>file_path: Target file</param>
      <param>old_string: Exact text to replace</param>
      <param>new_string: Replacement text</param>
      <param>replace_all: Replace all occurrences (optional)</param>
    </parameters>
  </tool>

  <tool name="Bash">
    <purpose>Execute shell commands</purpose>
    <criticality>Critical - testing, building, git operations</criticality>
    <best-practice>Chain related commands with && for atomicity</best-practice>
    <capabilities>
      <capability>Run tests: npm test, pytest</capability>
      <capability>Build: npm run build, cargo build</capability>
      <capability>Git: git status, git diff, git commit</capability>
      <capability>Install: npm install, pip install</capability>
    </capabilities>
    <danger>Can modify system, no undo - use carefully</danger>
  </tool>

  <tool name="Grep">
    <purpose>Search file contents with regex</purpose>
    <criticality>High - finding code patterns, references</criticality>
    <parameters>
      <param>pattern: Regex to search</param>
      <param>path: Directory or file to search</param>
      <param>type: File type filter (js, py, ts, etc.)</param>
      <param>output_mode: content (lines) | files_with_matches | count</param>
    </parameters>
  </tool>

  <tool name="Glob">
    <purpose>Find files by pattern</purpose>
    <criticality>Medium - discovering relevant files</criticality>
    <example>Glob("**/*.test.ts") finds all TypeScript test files</example>
  </tool>

  <tool name="TodoWrite">
    <purpose>Task tracking and planning</purpose>
    <criticality>High - prevents agent hallucination and lost context</criticality>
    <workflow>
      <step>Create todos with content and activeForm</step>
      <step>Mark one todo in_progress before starting</step>
      <step>Complete immediately after finishing</step>
      <step>Update with new todos as discovered</step>
    </workflow>
  </tool>

  <tool name="ken-you-remember (store_fr3k / recall_fr3k)">
    <purpose>Persistent memory across sessions</purpose>
    <criticality>Critical - prevents re-learning same lessons</criticality>
    <usage>
      <store>store_fr3k: "Database uses PostgreSQL 14, not MySQL"</store>
      <recall>recall_fr3k: "database setup" retrieves PostgreSQL info</recall>
    </usage>
    <limit>Max 500 chars per memory, max 5 retrieval results</limit>
  </tool>
</core-tools>

<advanced-tools>
  <tool name="MCP Servers">
    <description>Model Context Protocol servers for specialized capabilities</description>
    <examples>
      <example>mcp__grep__searchGitHub: Search public repos for code patterns</example>
      <example>mcp__snap-happy: Screenshot capabilities</example>
      <example>mcp__hey-daddy: Task management with validation workflow</example>
    </examples>
  </tool>

  <tool name="SlashCommand">
    <description>Execute custom workflows (debugging, deployment, refactoring)</description>
    <examples>
      <example>/debug: Fast problem identification workflow</example>
      <example>/check: Quality verification and test running</example>
      <example>/api: Complete API development with testing and docs</example>
    </examples>
  </tool>
</advanced-tools>

<optimization-strategies>
  <strategy name="Tool Chaining">
    <description>Combine tools for complex workflows</description>
    <example>
      1. Glob: Find all test files
      2. Grep: Search for specific test pattern
      3. Read: Load relevant test file
      4. Edit: Modify test
      5. Bash: Run test suite
      6. TodoWrite: Mark complete
    </example>
  </strategy>

  <strategy name="Parallel Tool Execution">
    <description>Agent can call multiple independent tools simultaneously</description>
    <example>
      Call Read on 3 files + Grep for pattern + Bash git status in single response
    </example>
    <benefit>5x faster than sequential tool use</benefit>
  </strategy>

  <strategy name="Tool Validation">
    <description>Use tools to verify other tool outputs</description>
    <pattern>
      1. Edit: Modify code
      2. Bash: Run linter to verify syntax
      3. Bash: Run tests to verify logic
      4. store_fr3k: Record success pattern
    </pattern>
  </strategy>

  <strategy name="Tool Specialization">
    <description>Use right tool for each job</description>
    <mapping>
      <task>Find files</task><tool>Glob (not Bash find)</tool>
      <task>Search content</task><tool>Grep (not Bash grep)</tool>
      <task>Read files</task><tool>Read (not Bash cat)</tool>
      <task>Modify code</task><tool>Edit (not Bash sed)</tool>
    </mapping>
  </strategy>
</optimization-strategies>

<tool-antipatterns>
  <antipattern name="Bash Overuse">
    <description>Using bash for tasks with dedicated tools</description>
    <example>
      Bad:  Bash: cat file.txt
      Good: Read: file.txt
    </example>
    <consequence>Less reliable, harder to parse output</consequence>
  </antipattern>

  <antipattern name="Write When Edit Appropriate">
    <description>Overwriting entire file for small change</description>
    <consequence>Risk of losing other changes, merge conflicts</consequence>
    <fix>Use Edit for surgical modifications</fix>
  </antipattern>

  <antipattern name="Tool Neglect">
    <description>Not using TodoWrite or ken-you-remember</description>
    <consequence>Agent loses track, repeats work, hallucinates</consequence>
    <fix>Use planning/memory tools proactively</fix>
  </antipattern>
</tool-antipatterns>
</leverage-point-4>

<core-four-synergy>
<principle>
The Core Four work together as a system. Optimize one, benefit from all.
</principle>

<synergy-examples>
  <example>
    <scenario>Debugging complex issue</scenario>
    <point1>CONTEXT: Provide error logs, relevant files, stack trace</point1>
    <point2>MODEL: Use Claude Sonnet 4.5 for reasoning depth</point2>
    <point3>PROMPT: "Analyze error, explain root cause, propose fix with reasoning"</point3>
    <point4>TOOLS: Read source files, Grep for references, Edit fix, Bash run tests</point4>
    <result>Root cause identified and fixed in single iteration</result>
  </example>

  <example>
    <scenario>Implementing new feature</scenario>
    <point5>CONTEXT: Load architecture docs, similar features, requirements</point5>
    <point2>MODEL: GPT-4 Turbo for balanced speed/quality</point2>
    <point3>PROMPT: "Implement [feature] following [pattern]. Add tests. No refactoring."</point3>
    <point4>TOOLS: TodoWrite plan, Edit implementation, Bash test, store_fr3k decisions</point4>
    <result>Feature complete with tests in one pass</result>
  </example>
</synergy-examples>

<optimization-order>
  <priority1>CONTEXT + PROMPT: Highest immediate impact</priority1>
  <priority2>TOOLS: Enable agent action capabilities</priority2>
  <priority3>MODEL: Fine-tune for task complexity</priority3>
</optimization-order>
</core-four-synergy>

<mastery-checklist>
  <checkpoint point="1">Can you articulate what context your agent needs before asking?</checkpoint>
  <checkpoint point="1">Do you proactively load relevant files?</checkpoint>
  <checkpoint point="2">Can you match task complexity to appropriate model?</checkpoint>
  <checkpoint point="2">Do you know when to escalate to stronger model?</checkpoint>
  <checkpoint point="3">Are your prompts specific, constrained, and measurable?</checkpoint>
  <checkpoint point="3">Do you provide examples and success criteria?</checkpoint>
  <checkpoint point="4">Do you use the right tool for each job?</checkpoint>
  <checkpoint point="4">Do you leverage TodoWrite and ken-you-remember consistently?</checkpoint>
</mastery-checklist>

<next-steps>
  <step>Practice Context loading: Before next task, list needed files</step>
  <step>Audit Prompts: Rewrite last 3 prompts with constraints + examples</step>
  <step>Tool proficiency: Use Edit instead of Write, Grep instead of Bash grep</step>
  <step>Study Through-Agent points for long-term infrastructure</step>
</next-steps>