Advertise hereReach developers building with AI coding agents. →

Based on Anthropic’s official docs, checked

Claude Code tips from Anthropic’s best practices

Claude Code’s defaults already do a lot: new terminal and VS Code sessions start in auto mode, Claude delegates to subagents on its own, and long conversations are compacted automatically. Anthropic’s best-practices page says the setup that pays off is for what Claude can’t see from the code: a deploy process in someone’s head, a file that must never be read, a check that has to pass, a budget to stay under. These tips are drawn from that page and the linked Claude Code docs, checked October 31, 2026.

  1. 1. Write a specific prompt

    Name the file, describe the symptom and say what fixed looks like. Anthropic’s example: instead of “fix the login bug”, say that login fails after the session times out, point at token refresh in src/auth/, and ask for a failing test before the fix. Type @ and a path to include a file, paste a screenshot, or pipe command output in.

    cat error.log | claude -p "what's going on here"
  2. 2. Keep CLAUDE.md short

    CLAUDE.md loads into every session, so keep only what Claude can’t work out from the repo: exact test, typecheck and lint commands, misleading code, team decisions and anything you have corrected twice. Start with /init, then remove lines; the memory guide recommends staying under 200. Run /context to confirm it loaded.

    # Commands
    - Run one test file: pnpm vitest run path/to/file.test.ts
    - Typecheck: pnpm tsc --noEmit
    
    # Gotchas
    - Integration tests need DATABASE_URL set, see .env.example
  3. 3. Give Claude a check to run

    Claude stops when work looks done. Give it something that returns pass or fail, such as a test file, a build exit code or a linter, and ask for the command and its output as evidence. For long background runs, /goal sets a condition Claude keeps working toward.

    /goal all tests in tests/auth pass and lint is clean
  4. 4. Turn must-never rules into deny rules

    A line in CLAUDE.md is followed almost every time, not every time. Deny rules hold in every permission mode, including auto and bypassPermissions, so put rules like never reading .env in .claude/settings.json.

    {
      "permissions": {
        "ask": ["Bash(git push *)"],
        "deny": ["Read(./.env)", "Read(./secrets/**)"]
      }
    }

Brainstorm before you build

When you don’t know exactly what you want, ask Claude to interview you until it could write the spec, then write it to SPEC.md. Start a fresh session to build from it, so the build begins with a clean context and a written definition of done.

When you want the fuller version of a feature, say “be ambitious” and list what you mean, such as empty and error states and keyboard navigation. Anthropic notes Claude otherwise tends to build the smallest thing that satisfies the request.

Use hooks for steps that must always happen

Hooks run your command at fixed points: before or after a tool call, when Claude tries to stop, when a session starts. A PostToolUse hook on Edit|Write can run your formatter after every edit, and a Stop hook that exits with code 2 sends Claude back to work until a typecheck passes.

Keep the enforced set small. Anthropic’s rule of thumb: if you keep adding emphasis to a CLAUDE.md line and Claude still misses it, it belongs in a hook; if a hook is only a preference, delete it.

Scope rules and put procedures in skills

A rule that matters in one part of the codebase goes in .claude/rules/ with a paths: filter, so it loads only when Claude works there.

Team procedures, like cutting a release, go in a skill at .claude/skills/<name>/SKILL.md. Claude sees only the name and description until the task needs it. Add disable-model-invocation: true for a workflow with side effects, so it runs only when you type its slash command.

Tune effort, model and permission mode

Effort is the main control for how long Claude thinks. Raise it with /effort high for subtle bugs or schema changes, lower it with /effort low for quick back-and-forth, and put ultrathink in a single prompt when only that turn needs it. Phrases like “think step by step” are ordinary text.

Shift+Tab cycles permission modes. If Manual asks too often, /fewer-permission-prompts adds your common read-only commands to an allowlist; if auto mode keeps blocking something routine, add it to autoMode.allow in ~/.claude/settings.json and keep "$defaults" in the list.

Steer early and reset often

Watch the first minute. Esc stops Claude mid-action and keeps the work; /rewind (or Esc twice on an empty prompt) rolls back code, conversation or both. After two failed corrections, run /clear and write one better prompt instead of a third correction.

Use /clear between unrelated tasks so the next one doesn’t pay for old history, /compact with a focus on long sessions, and /usage to see where your usage went.

Before you leave it running

Anthropic’s checklist for unattended runs: it knows what done looks like, can check its own work, can only touch what it should, has a cap such as --max-turns or --max-budget-usd, and a person signs off on the result. For parallel work, claude -w feature-auth starts a session in its own git worktree.

Tips

Next steps

Verified MCP servers for Claude

→

Generate an MCP config for Claude

→

Claude Code hub

→

Claude Code vs OpenAI Codex: documented features compared

→

Cursor vs Claude Code: documented features compared

→

Claude Code vs GitHub Copilot: documented features compared

→

Google Antigravity vs Claude Code: documented features compared

→

How to add an MCP server to Codex

→

How to add an MCP server to Cursor

→

How to add an MCP server to GitHub Copilot in VS Code

→

How to add an MCP server to Google Antigravity

→

How to migrate from Gemini CLI to Antigravity CLI

→

Portable agent skills: one SKILL.md for every coding agent

→

Safe “always allow” rules for Claude Code and Codex CLI

→

GitHub Copilot CLI yolo mode: --allow-all and safer tool rules

→

Codex sandbox modes and approval policies explained

→

How to install Claude Code on macOS, Linux and Windows

→

How to install the OpenAI Codex CLI

→

Claude Code auto mode: what runs, what gets blocked, how to turn it off

→

Agent Skills moves to the Agentic AI Foundation: what changes

→

MCP security: the risks in MCP servers and how to lock them down

→

Claude Code in VS Code: install, shortcuts and CLI differences

→

What is AGENTS.md? The open instruction file for coding agents

→

Claude Code on Windows: native, WSL and common errors

→

Codex skills: create, install and use SKILL.md skills in Codex

→

GitHub Copilot CLI: install, sign in and start using it

→

Cursor Agent SDK: build, test and deploy agents as code

→

GPT-6.1 Terra in Codex and the API: setup, pricing and limits

→

MCP OAuth: connect a remote MCP server in Claude Code, Codex and Cursor

→

Codex config.toml: location, precedence and the settings to change

→

Codex on Windows: native sandbox setup, WSL and fixes

→

Antigravity CLI (agy): install, sign in, modes and commands

→

Google Antigravity on Windows: install, WSL, sandbox and fixes

→

GitHub Copilot coding agent (now cloud agent): how to use it

→

GitHub Copilot agent mode: how to use it in your IDE

→

Claude Code with OpenRouter: setup, models and troubleshooting

→

How to add an MCP server: Claude Code, Codex, Cursor, Copilot and Antigravity

→

Supabase RLS for AI-built apps: grants, policies and tests

→

Antigravity skills: create, store and run SKILL.md skills

→

Claude Code in JetBrains IDEs: install, connect and fix issues

→

GitHub Copilot skills: create, install and use agent skills

→

Claude Code subagents: create, configure and run them

→

Check which plugins, hooks and MCP servers your agent loads

→

Cursor rules examples: .mdc files for each rule type

→

Fix spawn npx ENOENT when starting an MCP server

→

Frequently asked questions

Anthropic says it is the command that runs your check, such as your test or typecheck command, so Claude can verify its own work.

Sources