The Cost of Unstructured AI Coding
A terminal session that starts clean but crawls to a halt after three file updates. A billing alert from Anthropic showing a £30 charge for a single afternoon of coding. A git diff with 400 lines of unrelated lint fixes that nobody asked for. These are the signs of an AI coding session running out of control. Claude Code, Anthropic’s command-line interface, is a powerful tool for repository-wide edits, but running it without structured command discipline leads to token bloat and broken builds.
Many developers launch Claude Code and treat it like a standard browser chat, typing natural language instructions in a single, continuous stream. Within twenty minutes, the session context has swallowed the entire database schema, five utility functions, and three styling files. Every subsequent instruction now costs 80,000 input tokens, slowing down response times and inflating API bills. To make Claude Code useful, you must manage its active context, control its access permissions, and direct its editing behavior with precise commands.
This playbook breaks down the fourteen core commands in Claude Code. It explains how they work under the hood, when to execute them, and how to combine them into a clean developer workflow. By treating the CLI as a structured environment rather than a chat room, you can write code faster, reduce token bills by 60%, and keep your commit history clean.
Why Context Management Is the Real Issue
Claude Code operates by reading files from your local storage and compiling them into a prompt window sent to Anthropic’s models. When you ask it to modify a React component, it doesn’t just look at the component file; it also scans imports, inspects package.json, and reads your directory structure. This file accumulation represents the active context.
As the conversation grows, Claude Code keeps the entire history of modified files, terminal outputs, and previous prompts in memory. If you ask it to fix a bug, then write a test, then update a document in the same chat, the model reads the entire history on every turn. In a large Node.js project, this can quickly exceed 100,000 tokens per message. Managing this context window is not about saving a few pennies; it is about keeping the AI accurate. When the context window is bloated, the model is more likely to miss details, write duplicate code, or ignore project-specific rules.
The 14 Essential Commands
1. /init – Initialize Project Memory
The `/init` command establishes the foundation for how Claude Code understands your repository. When executed, it scans the root folder and generates a system memory template that helps guide subsequent interactions. This prevents the AI from having to guess your styling choices, package manager, or build configurations.
Execute this command when first setting up Claude Code in a repository. It creates a baseline understanding of the project layout, identifying key paths like `/src` or `/tests` and recognizing the project type (e.g. Next.js, Go, or Python).
Common Mistake: Skipping `/init` and letting the AI guess the build pipeline, which often leads to it running `npm run build` in a project that uses Yarn or pnpm.
JTech Recommendation: Always run `/init` as your very first step in a new repository. This ensures that all future code modifications align with your existing build scripts.
2. /memory – Refine Project Rules
The `/memory` command allows you to inspect and modify the active rules and project guidelines stored in your CLAUDE.md file. This file acts as a permanent instruction card that Claude Code reads at the start of every session, outlining coding standards, test commands, and styling rules.
Use this command when you need to update developer rules or when you notice the AI repeatedly making the same stylistic error, such as using default exports instead of named exports.
Common Mistake: Modifying the CLAUDE.md file manually with incorrect syntax, which can confuse the parser. Use the `/memory` command to let the CLI write the updates in a clean, structured format.
JTech Recommendation: Keep your project memory focused. Include the exact test command (e.g. `npm run test:unit`), the primary build script, and two or three strict styling rules. Do not list your entire development philosophy.
3. /plan – Enter Planning Mode
The `/plan` command switches Claude Code into a non-editing analysis mode. Instead of immediately modifying files, the AI reviews the codebase, maps dependencies, and outputs a step-by-step implementation plan for your approval.
Run this command before making wide-ranging architectural changes, refactoring multiple files, or implementing a new feature that touches both the frontend and backend database schemas.
Common Mistake: Asking the AI to make a major change without a plan, which often results in half-finished edits across five files that fail compilation.
JTech Recommendation: Start any task that affects more than two files with `/plan`. Review the proposed steps, adjust them in the prompt, and only proceed to implementation once the plan is solid.
4. /context – Inspect Token Usage
The `/context` command outputs a detailed breakdown of the current chat session context. It lists every file currently loaded into memory, the number of tokens each file consumes, and the total percentage of the context window used.
Execute this command when the CLI response time begins to slow down, or before running a command that you know will scan large files.
Common Mistake: Ignoring context size until the model returns a "context window exceeded" error, forcing you to lose your active chat history.
JTech Recommendation: Check `/context` every 15–20 messages. If a single file (like a large JSON dataset) is consuming more than 30% of your tokens, remove it from the chat or clear the session.
5. /compact – Compress Long Conversations
The `/compact` command shrinks the active chat log by summarizing the conversation history and removing outdated file contents from memory, while preserving the key decisions and state changes.
Use this when you are in the middle of a complex, multi-step debugging session and want to keep the current progress but need to reduce token consumption and improve model speed.
Common Mistake: Using `/compact` when you need to reference specific code snippets from early in the chat session, as those exact details may be lost in the summary.
JTech Recommendation: Run `/compact` when your session exceeds 50,000 tokens. This maintains the logical thread of your work while cleaning out unnecessary historical details.
6. /clear – Start Fresh
The `/clear` command deletes the active chat history and removes all loaded files from the session memory. It resets the terminal session to a completely clean state.
Use this when you have finished one task (such as fixing a bug in the database connection) and are starting a completely unrelated task (such as writing styling utilities for a login page).
Common Mistake: Carrying over files and conversation history from a completed task into a new one. This wastes tokens and risks the AI mixing context from the two tasks.
JTech Recommendation: Make `/clear` a habit. When Git status shows your current changes are tested and ready to commit, run `/clear` before tackling the next card.
7. /model – Switch Model for Task Difficulty
The `/model` command allows you to change the active LLM powering the CLI session, switching between fast, low-cost models and larger, high-reasoning models.
Execute this command to match the model to the task. For simple file edits, documentation writes, or minor CSS changes, switch to a faster model. For complex algorithms or database refactoring, switch to a high-reasoning model.
Common Mistake: Running a high-reasoning model for basic text edits, which unnecessarily increases your API usage fees.
JTech Recommendation: Use standard models for quick file operations, and switch to reasoning models only when you are debugging complex logic or starting a wide `/plan` session.
8. /effort – Adjust Reasoning Level
The `/effort` command controls the depth of analysis the model applies before generating code edits. It adjusts the trade-off between execution speed and reasoning quality.
Use this command when you hit a difficult bug and need the model to spend more compute time verifying edge cases, or when you are doing repetitive file renames and want responses instantly.
Common Mistake: Leaving reasoning effort set to maximum for simple, straightforward search-and-replace edits, which increases response latency.
JTech Recommendation: Set effort to low for routine tasks (like writing JSDoc comments or renaming variables) and raise it to high only when the model needs to work out a complex logical problem.
9. /permissions – Manage Approval Rules
The `/permissions` command displays and configures the security settings for Claude Code. It allows you to specify whether the AI can run shell commands, write files, or access the network without asking for your approval.
Use this command when setting up a repository for automated scripts, or when you want to restrict the AI from executing commands that might alter your database or run dangerous scripts.
Common Mistake: Setting permissions to allow all write and execute operations automatically in an unfamiliar repository, which could run malicious code.
JTech Recommendation: Keep permissions set to request approval for file modifications and shell executions. Reviewing the exact terminal command before pressing Enter is your best protection against codebase corruption.
10. /diff – Inspect Code Changes
The `/diff` command displays the exact changes made to the repository since the start of the current Claude Code session. It works similarly to standard `git diff`, showing additions and deletions in color.
Execute this command before approving a file write, or immediately after a complex code generation step to verify that the AI did not modify unrelated lines of code.
Common Mistake: Relying on the AI’s text summary of what it changed instead of inspecting the raw diff, which can lead to accidental changes in your repository.
JTech Recommendation: Run `/diff` before staging any changes. Inspecting the differences line-by-line ensures that you catch stray comments, incorrect indentation, or missing closing brackets.
11. /code-review – Review Current Diff
The `/code-review` command instructs Claude Code to analyze the active git diff in your working directory and identify potential bugs, performance bottlenecks, or style violations.
Run this command before committing your code, or prior to sending a pull request to your team. It acts as a pre-commit check to catch errors you might have missed.
Common Mistake: Running `/code-review` on a massive diff containing thousands of lines. Break your commits down into smaller, readable chunks so the review remains detailed and actionable.
JTech Recommendation: Use `/code-review` as a final sanity check. It is particularly good at catching forgotten console logs, incomplete test cases, or missing typescript types.
12. /review – Review a Pull Request
The `/review` command pulls down changes from a remote branch or pull request and conducts an automated code review, highlighting design issues, potential security flaws, or build risks.
Use this command when reviewing a colleague’s work, or when you want to perform a peer review on a branch before merging it into your main branch.
Common Mistake: Merging a pull request immediately after a review without testing the recommended fixes locally first.
JTech Recommendation: Run `/review` on incoming team contributions. Use the feedback to generate a list of requested changes, ensuring code quality stays high across the project.
13. /doctor – Diagnose Setup Problems
The `/doctor` command runs a diagnostic check on the Claude Code installation, your node dependencies, git configuration, and your terminal environment to identify configuration errors.
Execute this command when Claude Code begins behaving erratically, fails to read files, cannot connect to the Anthropic API, or experiences shell integration issues.
Common Mistake: Reinstalling the entire package manager or node version before running `/doctor` to pinpoint the specific path or credential error.
JTech Recommendation: Run `/doctor` whenever you switch development machines or update your global Node.js packages. It quickly catches missing environment variables and broken path configurations.
14. /usage – Monitor Cost and Usage
The `/usage` command outputs your API usage history for the active session and billing period. It details the number of input and output tokens consumed, the number of API calls, and the estimated cost in USD.
Run this command at the end of a coding session or after executing a large refactoring plan to monitor your spending and keep track of your budget limits.
Common Mistake: Forgetting to check usage during intensive development, which can lead to unexpected billing overages at the end of the month.
JTech Recommendation: Check `/usage` at the end of every working day. This builds a clear picture of which coding tasks consume the most tokens, helping you plan future work.
Frequently Asked Questions
Optimize Your AI Development Workflows
Want JTech to create a safe, cost-efficient, and reliable AI coding workflow for your project? Let us audit your repository setup and developer tooling.
