Claude Code best practices

AnthropicAbout 4 min readAug 1, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

  • Cloud Code: An AI coding assistant that uses a pure agent approach with tools for file manipulation, terminal access, and codebase exploration.
  • Agentic Search: The process by which Cloud Code explores and understands a codebase using search tools like glob, grep, and find.
  • claude.md: A markdown file used to provide Cloud Code with project-specific instructions, context, and style guides.
  • Permission Management: Controlling the actions Cloud Code can take, with options for auto-accepting certain commands.
  • Context Window: The limited amount of information Cloud Code can retain during a session (200,000 tokens for Anthropic models).
  • /clear: A command to clear the context window, except for claude.md.
  • /compact: A command to summarize the current session and seed the next session with the summary.
  • Think Hard/Extended Thinking: A mode where the model can think between tool calls, allowing for more complex reasoning.
  • MCP (Model Control Plane): A system for integrating external tools and services with Cloud Code.
  • Headless Automation: Using Cloud Code programmatically, such as in CI/CD pipelines.

What is Cloud Code?

Cal describes Cloud Code as a "co-worker that does everything on the terminal," akin to a highly skilled engineer proficient in command-line tools. It's designed to be a pure agent, meaning it operates based on instructions and tools, running in a loop until it determines the task is complete.

How Cloud Code Works

Cloud Code operates as a pure agent, utilizing powerful tools to interact with the codebase and the terminal. It doesn't rely on pre-indexing the codebase. Instead, it employs "agentic search," using tools like glob, grep, and find to explore and understand the code, similar to how a new team member would approach a new codebase. The UI provides a way to watch Claude code and a permission system to control potentially dangerous actions.

Use Cases for Cloud Code

Cloud Code is versatile and can be used for:

  • Discovery: Quickly understanding new codebases. Example: Asking Claude to explain the git history of a file.
  • Thought Partner: Exploring different implementation options before writing code. Example: Asking Claude to suggest multiple ways to implement a feature.
  • Building and Writing Code: Generating new code from scratch or working within existing codebases.
  • Testing: Easily adding unit tests to improve code coverage.
  • Deployment: Integrating with CI/CD pipelines using the Cloud Code SDK.
  • Support and Scale: Debugging errors and assisting with large codebase migrations (e.g., Java to a newer version, PHP to React).
  • CLI Tooling: Interacting with tools like Git, Docker, and BigQuery.

Best Practices for Using Cloud Code

1. Use claude.md Files

  • claude.md files provide Cloud Code with essential context and instructions.
  • They can be placed in the project directory (for team-wide context) or the home directory (for personal preferences).
  • Examples of content: project overview, testing instructions, style guides.
  • You can reference other files using the @ symbol.

2. Permission Management

  • Cloud Code requires permission for write actions and running bash commands.
  • Use auto-accept mode (Shift+Tab) or configure settings to automatically approve specific commands (e.g., npm run test).

3. Integration Setup

  • Leverage CLI tools (e.g., GitHub CLI - gh) to extend Cloud Code's capabilities.
  • Integrate internal tools by providing Cloud Code with information about them in claude.md.

4. Context Management

  • Be aware of the context window limit (200,000 tokens).
  • Use /clear to reset the context (except for claude.md).
  • Use /compact to summarize the session and start a new session with the summary.

5. Efficient Workflows

  • Use planning and to-do lists: Ask Cloud Code to create a plan before starting work.
  • Pay attention to the to-do list and interrupt if necessary (using Escape).
  • Practice "smart vibe coding": Use test-driven development, make small changes, run tests, check TypeScript/linting, and commit regularly.
  • Use screenshots to guide and debug.

6. Advanced Techniques

  • Run multiple Cloud Code instances simultaneously.
  • Use Escape to interrupt and redirect Cloud Code. Pressing escape twice allows you to jump back in your conversation.
  • Explore MCP servers for integrating more specialized tools.
  • Experiment with headless automation.

New Features and Updates

  • Model Selection: Use /model to switch between different Claude models (e.g., Sonnet, Opus).
  • Think Hard: Claude models can now "think" between tool calls, allowing for more complex reasoning. Triggered by including "think hard" in the prompt.
  • VS Code and JetBrains Integrations: Improved integrations with IDEs, allowing Cloud Code to be aware of the current file.

Conclusion

Cloud Code is a powerful AI coding assistant that can significantly enhance developer productivity. By understanding how it works, leveraging best practices, and staying up-to-date with new features, developers can maximize its potential for tasks ranging from codebase discovery to complex code generation and deployment. The key is to treat Cloud Code as a collaborative partner, guiding it with clear instructions, monitoring its progress, and intervening when necessary.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.