# Claude Code Training — Cheatsheets

---

## Prompt Modes & Input Prefixes

## Prompt modes

| Mode | How to activate | What Claude can do | When to use |
|------|-----------------|-------------------|-------------|
| Default | Launch Claude Code (always on by default) | Read files, edit files, run commands | Most everyday work |
| Plan | `Shift+Tab` twice, or `/plan` | Read and reason only — no edits, no commands | Before large or risky changes |
| Accept edits | `Shift+Tab` once | Auto-apply file edits without per-change confirmation | Trusted batch edits after reviewing a plan |

## Input prefixes

| Prefix | Name | Purpose | Example |
|--------|------|---------|---------|
| `@` | File reference | Include a specific file or directory in context | `@src/model.py` |
| `!` | Shell command | Run a command inline and pass its output to Claude | `! pytest tests/ -v` |
| `&` | Background task | Run a command in the background; Claude keeps responding | `& python src/train.py` |

---

## Tokens, Context & Pricing

## Term definitions

| Term | Definition |
|------|------------|
| Token | The basic unit of text processed by the model. Roughly 3–4 characters or ¾ of an English word. |
| Context window | The total space available for the current session: CLAUDE.md + conversation + files + tool outputs. |
| Input tokens | All tokens sent to the model in a request. Includes everything in the context window at that moment. |
| Output tokens | Tokens in Claude's response. Billed at a higher rate than input tokens. |
| `/cost` | Claude Code command that reports token usage and estimated cost for the current session. |

## Model cost tiers (relative)

| Model | Speed | Cost | Best for |
|-------|-------|------|----------|
| Haiku | Fastest | Cheapest | Quick lookups, simple edits, high-volume tasks |
| Sonnet | Balanced | Mid-range | Default for most Claude Code work |
| Opus | Slowest | Most expensive | Complex reasoning, architecture decisions |

*Exact per-token pricing changes. Check [anthropic.com/pricing](https://www.anthropic.com/pricing) for current rates.*

---

## CLI Commands

## All commands

| Command | Purpose | Example |
|---------|---------|---------|
| `claude` | Open interactive session | `$ claude` |
| `claude "..."` | Session with initial prompt | `$ claude "explain src/pipeline.py"` |
| `claude --model <id>` | Open session with specific model | `$ claude --model opus` |
| `claude --help` | Show CLI flags | `$ claude --help` |
| `/help` | List all slash commands | `/help` |
| `/clear` | Wipe conversation history | `/clear` |
| `/compact` | Compress history, keep recent context | `/compact` |
| `/cost` | Show token usage and cost | `/cost` |
| `/model` | Switch model mid-session | `/model` |
| `/plan` | Toggle Plan mode (no file edits) | `/plan` |
| `/init` | Generate CLAUDE.md for current project | `/init` |
| `! <cmd>` | Run shell command inline | `! git status` |
| `& <cmd>` | Run command in background | `& python src/train.py` |
| `@<file>` | Add file to context (input prefix, not a command) | `@src/train.py` |

---

## Custom Commands

## Where commands live

```
.claude/
└── skills/
    ├── review-notebook/
    │   └── SKILL.md          # → /review-notebook
    ├── summarize-pr/
    │   └── SKILL.md          # → /summarize-pr
    └── check-leakage/
        └── SKILL.md          # → /check-leakage
```

## Naming convention

- Directory name becomes the command name
- Use kebab-case: `review-pr`, not `reviewPR` or `review_pr`
- Keep names short and action-oriented: `/doc`, `/review`, `/test`

## SKILL.md structure

```markdown
---
name: review-notebook
description: Review a Jupyter notebook for reproducibility and data leakage
---
Review the notebook at $ARGUMENTS for...
```

## `$ARGUMENTS` syntax

| You type | `$ARGUMENTS` value |
|----------|--------------------|
| `/review src/model.py` | `src/model.py` |
| `/compare models/v1.pkl models/v2.pkl` | `models/v1.pkl models/v2.pkl` |
| `/review` (no argument) | *(empty string)* |

## How to invoke

Skills in `.claude/skills/` are loaded automatically — no activation step needed.

```bash
$ claude
> /review-notebook notebooks/churn_model.ipynb
> /summarize-pr #87
> /check-leakage src/features/
```

---

## Token Reduction Strategies

## Techniques at a glance

| Technique | When to use | Token impact |
|-----------|-------------|--------------|
| `@file` | Target a specific file | High — avoids broad exploration |
| `cd` into subdirectory | Working on one component | Medium — narrows file discovery scope |
| `/clear` | Starting a new, unrelated task | High — resets full history |
| `/compact` | Mid-task, context growing large | Medium — compresses history to summary |
| Trim CLAUDE.md | Always — keep under 500 words | Medium — saves tokens on every session |
| Move instructions to skills | When instructions are task-specific | Medium — loads only when invoked |
| MCP retrieval tool | Large codebase, semantic search needed | High — loads relevant chunks, not whole files |
