Context and cost awareness
Course contents (20 lessons)
- Meet Claude Code
- What Claude Code is and how it differs from a chat window
- Installing Claude Code and signing in
- Your first session: explore, ask, change
- Asking well and staying in control
- Asking for changes: context, goal, constraints and acceptance criteria
- Reading and approving edits
- Permission modes: how much freedom to give
- Project memory and slash commands
- CLAUDE.md: teaching the tool about your project
- Slash commands and custom commands
- Everyday coding workflows
- The plan-first workflow
- Understanding unfamiliar code
- Debugging with Claude Code
- Refactoring safely
- Writing tests with Claude Code
- Git, small changes, cost and security
- Git workflows: branches, commits and pull request descriptions
- Keeping changes small and reviewable
- Context and cost awareness
- Security habits: secrets, commands and untrusted input
- Extending the tool, teamwork and a final project
- Hooks and MCP servers explained
- Team practices for AI-assisted coding
- Final project: building a small app step by step
What context means
A language model reads text in a limited window. In a coding session, that window holds your messages, the tool's replies, the files it has read, command output and the project memory file. When it fills up, older material must be dropped or summarised. Everything in the window is something the model must pay attention to.
This has two effects. Quality: a window crowded with old, irrelevant material gives worse answers. Cost: usage is measured in tokens, which are small pieces of text. How you are charged, or how your usage limits work, depends on your plan. I will not quote numbers or prices because they change. Check the official pages for the current rules.
Habits that keep context healthy
- One task per session. Finish, commit,
/clear. - Scope the reading. Point at the folder or file instead of "look at the whole project".
- Keep CLAUDE.md short. It loads every time.
- Use
/compactwhen a task is long and the thread is worth keeping. - Avoid huge outputs. Do not ask it to print a 5,000-line log into the conversation.
Scoped versus broad
Compare:
Find all the bugs in the project.
Review src/Payments/RefundService.cs for bugs related to partial refunds. Only read that file and the tests for it, plus any file you need to understand a call. Report at most 5 issues.
Why the second is better
The first makes the tool read a large part of the codebase and return a long, shallow list. The second has a target, a topic and a limit. It costs less, finishes sooner and the result is easier to check. Narrow questions get sharp answers.
Trim noisy output
Test runs and builds can print hundreds of lines. When you ask for a command to be run, say how to limit the output:
Run the tests for the Payments project. In your report, give me only the failing test names and their first error line, not the full output.
Test runners often have options for less output. Ask the tool to use them, and check your tool's documentation for the flag names.
Know when a session has gone stale
Signs that it is time to clear or compact: the tool forgets a decision you made earlier, repeats a suggestion you rejected, becomes slower, or contradicts earlier edits. Do not fight it. Summarise the state in a few lines, clear, and continue.
Before I clear this session, write a 10-line summary: what we are building, decisions made, files changed, what is done, what remains and any failing tests. I will paste it into the next session.
Pasting that summary into a fresh session recovers the thread at a small cost.
Choose models sensibly
The tool lets you choose between different models. In general, larger models handle complex reasoning and multi-file changes better, and smaller ones are faster and cheaper for simple tasks. The names and options change, so check the current list in the tool and in the documentation. A reasonable plan is a stronger model for planning and hard bugs, and a lighter one for routine edits, if your plan allows the choice.
Watch your usage
The tool has ways to show usage in the session; look at /help and the official docs for the current commands. If you pay per use, check it regularly during your first weeks, so a habit does not surprise you at the end of the month. If you are on a plan with limits, notice which habits burn through them quickly: usually long sessions, huge pastes and broad searches.
Do not over-optimise
Saving tokens is good, but your time is worth more than a few tokens. If a broader prompt saves you an hour of fumbling, it is worth it. The goal is to avoid waste, such as dragging a stale conversation along, not to starve the tool of useful context.
The common mistake
The common mistake is running one endless session for days. It is easy and feels convenient. It is also the main cause of drifting answers and high usage. Short, focused sessions with notes between them work better.
Try it yourself
For one working day, follow the rule of one task per session. At the end of each task, write down how long it took and whether you had to repeat yourself. Compare with a day when you let a session run on. You should see a difference in how often the tool forgot or confused things.
This course is free to read. Create a free account to enrol, save your progress and pick up where you left off.
Sign up free I already have an account