Contents
Claude Code: Cost Management and Chunking (Part 1)

Claude Code: The Holy Grail of Agentic Development

I'll say it openly: Claude Code is the tool I enjoy working with most. Not because it is new, but because, when configured properly, it can save 70–80% of the time spent on routine tasks.

But beware: if you simply start claude and let it work without setting boundaries, you can end up with a high bill and frustrating results. Claude Code is powerful, but it requires discipline and proper configuration.

First, the hard reality: cost management is critical

Many developers make this mistake:

bash
# ❌ BAD: Run Claude Code across everything
cd ~/projects
claude "Fix all the bugs in my projects"

# Result:
# - Searches 50+ projects
# - Consumes millions of tokens
# - Bill: $300+
# - Results: chaotic

A better approach:

bash
# ✅ GOOD: Focus on a specific project
cd ~/projects/qaron-platform/backend
claude "Optimize these three specific SQL queries in OrderService"

# Result:
# - Focused on one service
# - Consumes thousands of tokens
# - Bill: $5–10
# - Results: precise and usable

Rules for saving tokens

1. Limit the scope

bash
# Instead of:
cd ~/all-projects
claude "Find and fix security issues"

# Use:
cd ~/project-a/src/auth
claude "Review this AuthService.java for security issues"

2. Do not give access to projects you do not need

json
// .claude/config.json
{
  "excludedDirectories": [
    "node_modules",
    ".git",
    "dist",
    "build",
    "coverage",
    "*.log",
    "tmp",

    // ❌ Exclude projects outside the current task
    "../other-unrelated-project",
    "../archived-projects"
  ]
}

3. Chunking: break large tasks into smaller ones

bash
# ❌ BAD: One enormous task
claude "Create a complete e-commerce platform with authentication,
payments, inventory management and an admin panel"

# ✅ GOOD: Chunked sub-tasks
# Task 1:
claude "Create user authentication with JWT"

# Task 2 (after task 1):
claude "Add Stripe payment integration"

# Task 3:
claude "Implement inventory management"

Why chunking works:

  • AI can complete simple tasks faster without getting sidetracked
  • Less context means fewer tokens
  • Iterative improvement lets you review each step
  • It resembles a real development process

A real-life analogy

Imagine a tester sends you this bug report:

Bug: "It doesn't work"

Your reaction: “What doesn't work? How did you get there? What steps did you take?”

You need more information to solve the problem successfully. The same applies to AI:

bash
# ❌ BAD: Vague prompt
claude "Fix the login bug"

# ✅ GOOD: Detailed prompt
claude "The login endpoint returns a 500 error when the username contains
special characters (@, #). The error is in UserValidator.java on line 45.
Fix validation to support email format."

Rule: The more relevant information you give the AI, the sooner you can get the expected result.

Frontend + backend strategy: one or two Claude Code instances?

This strategic decision affects both cost and efficiency.

Scenario 1: Two separate Claude Code instances (frontend + backend)

bash
# Terminal 1: Frontend
cd ~/project/frontend
claude "Implement the user profile page"

# Terminal 2: Backend
cd ~/project/backend
claude "Create the /api/user/profile endpoint"

Advantages:

  • ✅ Lower token consumption per session
  • ✅ Parallel work on frontend and backend
  • ✅ Simpler context management

Disadvantages:

  • ❌ Manual synchronization of the API contract
  • ❌ Duplicate work because each side cannot see the other
  • ❌ Potentially inconsistent data models

Scenario 2: One Claude Code instance with access to both

bash
# Terminal: Whole project
cd ~/project
claude "Implement the user profile feature:
1. Backend: GET /api/user/profile endpoint
2. Frontend: ProfilePage component with API integration
3. Ensure a consistent User model on backend and frontend"

Advantages:

  • ✅ Holistic approach: it can see the whole picture
  • ✅ Automatic synchronization: the API contract stays consistent
  • ✅ Less manual work connecting frontend and backend

Disadvantages:

  • ❌ Higher token consumption because both sides are searched
  • ❌ Slower on large codebases
bash
# 1. Backend generates the contract
cd ~/project/backend
claude "Create the /api/user/profile endpoint and generate an
OpenAPI spec in docs/api-spec.yaml"

# 2. Frontend uses the contract
cd ~/project/frontend
claude "Implement ProfilePage according to
../backend/docs/api-spec.yaml. Use axios and TypeScript types."

Advantages:

  • ✅ Lower costs because each agent sees only its part
  • ✅ A clear API contract (OpenAPI spec)
  • ✅ Type safety with TypeScript types derived from the backend API

Or use a Markdown communication file:

bash
# Backend generates integration instructions for the frontend
cd ~/project/backend
claude "Create the user profile endpoint and document how the frontend
should integrate it in docs/FE_INTEGRATION.md"

# Frontend reads the instructions
cd ~/project/frontend
claude "Implement the profile page according to
../backend/docs/FE_INTEGRATION.md"

In the next part, we will look at CLAUDE.md, your development constitution, and how to create a virtual team of agents.

All articles