How to use Claude Code: a working loop on a real task

One full pass with Claude Code, from writing the task to the commit. How to read the diff, undo edits and keep token spend under control.

5 min · · development · агенты

If you have installed Claude Code and are staring at an empty prompt, the question "how to use Claude Code" comes down to one thing: which steps take you from a task to a working commit. Below is one loop on a concrete example: a test fails in a Python project, and you need to find the cause, fix it and commit. We skip installation and key setup here; see the setup-from-scratch article and the documentation page.

Before you start: clean tree and a branch

The main safety net when an agent edits files is git. Before the session:

bash
cd ~/projects/billing-service
git status          # the working tree should be clean
git switch -c fix/date-parsing
claude

A clean tree means the diff after the session contains only the agent's edits. A separate branch means any failed result can be thrown away with one command.

If Claude Code is connected through a gateway, the variables look like this (details are in the docs):

bash
export ANTHROPIC_BASE_URL=https://api.zukko.pro
export ANTHROPIC_AUTH_TOKEN=fetch_your_key
export ANTHROPIC_MODEL=claude-sonnet-5-5

The address has no /v1 here: Claude Code adds the path itself. The variable is specifically ANTHROPIC_AUTH_TOKEN.

How to write the task

A bad request: "fix the tests". The agent has to guess which tests, what counts as success and what is off limits. A good request has four parts: the goal, where to look, constraints and how to verify.

bash
Test tests/test_dates.py::test_parse_month_end fails on the last day of a month.
Find the cause in app/dates.py and fix it.
Do not change public function signatures and do not touch other tests.
Verify with: pytest tests/test_dates.py -q

The verification command matters most. If the agent can run the test and see the result itself, it iterates: edit, run, read the error, edit again. Without a verification command you get plausible code that nobody ran.

Put standing project rules (how to run tests, code style, what must not change) into a CLAUDE.md file in the repository root so you do not repeat them in every request: how to write it.

Plan first, edits second

For a non-trivial task, ask for a plan without changes first. The interactive session has a planning mode; you can cycle through permission modes with Shift+Tab (the exact set of modes depends on the version, check /help). You can also simply write in the request: "first describe the plan and wait for my confirmation".

Read the plan like a reviewer. Typical red flags: the agent intends to rewrite neighbouring modules "while at it", add a dependency for one function, or change a test so it passes. Stop the last one immediately: a test is edited only if the mistake is in the test itself.

How to read the diff

Claude Code shows edits as it goes and asks permission for actions until you switch to a looser mode. While you are learning, do not click "allow all" on autopilot. When it finishes, look at the result in git, not only in the agent window:

bash
git diff --stat      # how many files and lines changed
git diff             # the edits themselves

What to check:

  • Only the expected files are touched. An unexpected file in --stat is a reason to ask the agent why it changed it.
  • No "side cleanup": renames, reformatting a whole file, deleted comments.
  • New code does not silence the error (except Exception: pass, a skipped test, a weakened condition in a check).
  • You ran the tests yourself, not only the agent: pytest -q.

How to roll back

Always roll back with git rather than by asking the agent:

bash
git restore app/dates.py        # discard edits in one file
git restore .                   # discard all uncommitted edits
git switch main && git branch -D fix/date-parsing   # discard the whole branch

If the result is half good, commit the good part and discard the rest. Some versions of Claude Code can return the session to an earlier step, but that complements git rather than replacing it; check the capabilities of your version in the tool's documentation.

Token spend: what to do along the way

On every step the agent sends the model the accumulated conversation, so cost grows faster than the length of your text. Three habits keep spend in check:

  1. One task, one session. Finished a bug? Start the next one with a clean context using /clear. For a long task there is /compact, which compresses the history.
  2. Do not ask it to "study the whole project". Name files and directories.
  3. Match the model to the task: a cheaper one is enough for routine work like this bug, try a stronger one for a complex refactor. Switch with /model.

Let us estimate the cost of our bug fix without cache. Say 20 model requests, on average 40,000 input tokens and 1,000 output tokens each (illustrative numbers). Formula without cache: input × input price + output × output price. Prices as of October 18, 2026:

  • claude-sonnet-5-5: 0.8M × 0.4 + 0.02M × 2 = 0.32 + 0.04 = $0.36.
  • claude-opus-5-5: 0.8 × 0.8 + 0.02 × 4 = 0.64 + 0.08 = $0.72.

In the Anthropic format that Claude Code uses, the repeating part of the context is read from cache: for claude-sonnet-5-5 a cache read costs $0.05 per 1M versus $0.4 for input, and a cache write $0.5. Since a long session has far more reads than writes, the real sum is usually lower than the estimate. See exact spend in the "Usage" section of the dashboard, and the model list with prices via GET https://api.zukko.pro/v1/models. To keep an agent from running up a bill, set a daily limit on the key: how to do it.

The commit

When the check has passed and you are happy with the diff:

bash
pytest -q
git add -p                      # choose exactly what to commit
git commit -m "Fix month-end parsing in parse_date"

You can ask the agent to propose a commit message from the diff, but make the commit yourself: it is the last point of control.

FAQ

Where do I start if the project is big?

With a small task that has a clear check: a bug with a reproducible test, one endpoint, one script. That shows how the agent behaves on your code before you trust it with a refactor.

Should I let the agent run any command?

No. While you get used to it, confirm commands, and permanently allow only things like running tests and reading files. Keep dangerous operations (deleting, push, anything touching production) for yourself. Concrete permission settings are in the tool's documentation.

Why did the session cost more than I expected?

Usually because of a long history and large files in context. Start a new session for a new task, narrow the search area and look at per-request spend in the dashboard.

Does this work with payment from Russia?

Access from Russia goes through the gateway; you can top up the balance via SBP (the payment page adds an 8.5% fee), with a MasterCard card or with cryptocurrency.

To repeat this loop on your own project, create a key in the dashboard, connect Claude Code and start with one small bug.

zukko

Pay 25×
less

for Claude Code & ChatGPT

One fetch_* key and base URL api.zukko.pro — for Cursor, Claude Code, Codex, and any SDK.

Get API keyDocumentation

api.zukko.pro · fetch_*

How to use Claude Code: from task to commit · Zukko