Best practice of Claude Code

In the ever-evolving landscape of software development, AI-powered tools are no longer a novelty but a necessity for staying competitive and productive. Among these, Anthropic’s Claude Code has emerged as a transformative force, empowering both seasoned developers and non-technical professionals to build, debug, and innovate faster than ever before.

This guide goes beyond the surface-level tips and delves deep into the best practices that Anthropic’s own teams have honed through their daily use of Claude Code. Whether you’re a data engineer wrestling with complex pipelines, a product designer bridging the gap between vision and reality, or a marketer looking to automate your workflows, these insights will help you unlock the full potential of this powerful AI assistant.

claude code

 

The Foundation of Success: Universal Best Practices

 

Before we explore the team-specific strategies, it’s crucial to understand the fundamental principles that underpin successful collaboration with Claude Code:

  • The Art of the Prompt: The quality of your output is directly proportional to the quality of your input. Be clear, specific, and provide as much context as possible. Think of yourself as a project manager delegating a task to a talented but literal-minded assistant.
  • Iterative Collaboration: Don’t expect a perfect solution on the first try. Treat Claude Code as an iterative partner. Start with a simple prompt, review the output, and then refine your request with additional instructions. This back-and-forth process is where the magic happens.
  • Embrace Autonomous Workflows: For many tasks, you can set Claude Code to work autonomously and check in periodically. This is especially effective for prototyping, writing tests, and other non-critical path activities. You’ll be amazed at what it can accomplish while you focus on other priorities.

 

Team-Specific Strategies for Maximum Impact

 

Data Infrastructure: Automating and Securing Your Data Pipelines

 

The Data Infrastructure team at Anthropic relies on Claude Code to manage the massive datasets that fuel their research and development. Their best practices are a masterclass in efficiency and security:

  • The Power of Claude.md: Create a comprehensive Claude.md file in your project directory. This file should act as a “user manual” for Claude, outlining your team’s specific workflows, preferred tools, and coding conventions. A well-crafted Claude.md can transform Claude from a general-purpose assistant into a specialized team member.
  • Security First: When dealing with sensitive data, always prioritize security. The Data Infrastructure team recommends using MCP servers instead of the BigQuery CLI to ensure that you have granular control over data access and permissions.
  • Knowledge Sharing is Key: Regularly hold team sessions to share and demonstrate new Claude Code workflows. This not only helps to disseminate best practices but also sparks new ideas for how to leverage the tool in innovative ways.

 

Product Development: Building a Self-Sufficient Development Loop

 

The Claude Code team is at the forefront of using their own product to build, test, and deploy new features. Their best practices are a testament to the power of “dogfooding”:

  • The “Test-First” Approach: One of the most effective ways to ensure code quality is to have Claude generate tests before it writes the actual code. This forces a clear definition of the desired functionality and makes it easier to verify the final output.
  • Task Triage: Sync vs. Async: Develop an intuition for which tasks are best suited for asynchronous work and which require your direct supervision. Prototyping a new feature? Let Claude run wild. Fixing a critical bug in your core business logic? Keep a close eye on its work.
  • Clarity is King: When working in a complex codebase with multiple components that have similar names, be extra specific in your prompts. The more context you provide, the less likely Claude is to get confused and the more you can trust it to work independently.

 

Security Engineering: Hardening Your Defenses with AI

 

The Security Engineering team at Anthropic uses Claude Code to proactively identify and mitigate security vulnerabilities. Their strategies are a blueprint for building a more secure software development lifecycle:

  • Custom Slash Commands for the Win: Don’t be afraid to create your own custom slash commands to automate repetitive security tasks. The Security Engineering team has created over 50 custom commands to streamline everything from dependency scanning to vulnerability patching.
  • Let Claude Take the Wheel: For complex security investigations, resist the urge to micromanage. Instead, provide Claude with a high-level goal and let it work autonomously. You might be surprised by the creative and effective solutions it comes up with.
  • Documentation on Autopilot: Claude Code is a powerful tool for generating and synthesizing documentation. Provide it with a few writing samples and your preferred formatting, and it can create high-quality documentation that you can use in your wikis, READMEs, and other internal resources.

 

Data Science and ML Engineering: From Raw Data to Production-Ready Dashboards

 

The Data Science and ML Engineering teams use Claude Code to bridge the gap between research and production. Their best practices are a guide for anyone looking to turn data into actionable insights:

  • The “Slot Machine” Strategy: For complex refactoring tasks, don’t be afraid to take a chance. Save your current state, let Claude work its magic, and if the result isn’t what you’re looking for, simply roll back and try again. Sometimes a fresh start is the fastest path to a solution.
  • The Power of “Simpler”: If Claude provides a solution that is overly complex or difficult to understand, don’t hesitate to ask for a simpler approach. The model is often capable of generating more elegant and efficient solutions when prompted to do so.

 

API Knowledge: Navigating the Unknowns of a Large Codebase

 

The API Knowledge team is responsible for ensuring that Claude has access to the information it needs to answer user queries accurately. Their best practices are a must-read for anyone who works in a large and complex codebase:

  • Embrace the “Beginner’s Mind”: When tackling a bug or investigating an incident in an unfamiliar part of the codebase, let Claude be your guide. It can help you ramp up quickly and make meaningful contributions without a lot of prior knowledge.
  • Start Small, Think Big: Instead of overwhelming Claude with a massive amount of information upfront, start with the bare minimum and let it ask for more context as needed. This more natural, conversational approach can often lead to better results.

 

Growth Marketing: Automating Your Way to Success

 

The Growth Marketing team uses Claude Code to automate repetitive tasks and create sophisticated, multi-step workflows. Their strategies are a goldmine for anyone looking to do more with less:

  • Identify Your Automation Opportunities: Look for tasks that are repetitive, rule-based, and involve tools that have APIs. These are the low-hanging fruit for automation with Claude Code.
  • Divide and Conquer: For complex workflows, break them down into smaller, more manageable sub-tasks and create specialized sub-agents for each one. This makes it easier to debug problems and improves the overall quality of the output.
  • Plan Before You Prompt: Before you write a single line of code, take the time to map out your entire workflow. This will help you to create a more comprehensive and effective prompt for Claude Code.

 

Product Design: From Static Mockups to Functional Prototypes

 

The Product Design team uses Claude Code to bridge the gap between design and engineering, turning static mockups into interactive prototypes with unprecedented speed. Their best practices are a game-changer for any design team:

  • Don’t Go It Alone: The initial setup for Claude Code can be a bit challenging for non-developers. Don’t be afraid to ask for help from your engineering colleagues. A little bit of upfront investment will pay huge dividends down the road.
  • The Power of the Paste: One of the most powerful features of Claude Code is the ability to paste images directly into the prompt. This allows you to turn static mockups into functional code with just a few clicks.
  • Custom Memory for the Win: Create a Claude.md file with specific instructions on how you want Claude to behave. This is especially helpful if you have little to no coding experience, as it can help to guide the model and improve the quality of its responses.

 

RL Engineering: Supercharging Your Reinforcement Learning Workflows

 

The RL Engineering team uses Claude Code for everything from writing small features to debugging complex reinforcement learning algorithms. Their strategies are a must-read for anyone working in this cutting-edge field:

  • The One-Shot Approach: For many tasks, it’s worth giving Claude a quick prompt and letting it attempt the full implementation in one shot. If it works, you’ve saved yourself a ton of time. If not, you can always switch to a more collaborative, back-and-forth approach.
  • Checkpoint Your Work: When you’re experimenting with new ideas, it’s always a good idea to commit your work frequently. This makes it easy to roll back to a known good state if things go wrong.

 

The Future is a Collaboration

 

The best practices outlined in this guide are not just a set of rules to be followed blindly. They are a starting point for your own journey of discovery with Claude Code. As you become more comfortable with the tool, you will undoubtedly develop your own unique workflows and strategies.

The key is to approach Claude Code not as a vending machine for code, but as a true collaborator. By combining your own creativity and expertise with the power of AI, you can unlock new levels of productivity, innovation, and fun in your work. So go ahead, dive in, and start building the future, together.

Combining tmux and Claude to Build an Automated AI Agent System (for Mac & Linux)

1. Introduction

With the rapid growth of AI, multi-agent systems are attracting more attention due to their ability to coordinate, split tasks, and handle complex automation. An “agent” can be an independent AI responsible for a specific role or task.

In this article, I’ll show you how to combine tmux (a powerful terminal multiplexer) with Claude (Anthropic’s AI model) to build a virtual organization. Here, AI agents can communicate, collaborate, and work together automatically via the terminal.

 

2. What is tmux?

tmux lets you split your terminal into multiple windows or sessions, each running its own process independently. Even if you disconnect, these sessions stay alive. This is super useful when you want to run several agents in parallel, each in their own terminal, without interfering with each other.

 

3. What is Claude?

Claude is an advanced language AI model developed by Anthropic. It can understand and respond to text requests, and it’s easy to integrate into automated systems—acting as a “virtual employee” taking on part of your workflow.

 

4. Why combine tmux and Claude?

Parallel & Distributed: Each agent is an independent Claude instance running in its own tmux session.

Workflow Automation: Easily simulate complex workflows between virtual departments or roles.

Easy Debug & Management: You can observe each agent’s logs in separate panes or sessions.

 

5. System Architecture

Let’s imagine a simple company structure:

PRESIDENT: Project Director (sets direction, gives instructions)

boss1: Team Leader (splits up tasks)

worker1, worker2, worker3: Team members (do the work)

Each agent has its own instruction file so it knows its role when starting up.

Agents communicate using a script:

./agent-send.sh [recipient] “[message]”

Workflow:

PRESIDENT → boss1 → workers → boss1 → PRESIDENT

 

6. Installation

Since the code is a bit long, I’ll just share the GitHub link to keep things short.

tmux:
Install guide: tmux Installing Guide

Claude:
Install guide: Claude Setup Guide

Git:
Install guide: Git Download

Clone the project:

bash
git clone https://github.com/mhieupham1/claudecliagent

 

Inside, you’ll find the main folders and files:

CLAUDE.md: Describes the agent architecture, communication, and workflows.

instructions/: Contains guidance for each role.

.claude/: JSON files to manage permissions for bash scripts.

setup.sh: Launches tmux sessions for PRESIDENT, boss1, worker1, worker2, worker3 so agents can talk to each other.

agent-send.sh: Script for sending messages between agents.

 

7. Deployment

Run the setup script:

bash
./setup.sh
This will create tmux sessions for PRESIDENT and the agents (boss1, worker1, worker2, worker3) in the background.

To access the PRESIDENT session:

bash
tmux attach-session -t president


To access the multiagent session:

bash
tmux attach-session -t multiagent


In the PRESIDENT session, run the claude command to set up the Claude CLI.

Do the same for the other agents.

Now, in the PRESIDENT window, try entering a request like:

you are president. create a todo list website now
PRESIDENT will start the to-do list. PRESIDENT will send instructions to boss1, boss1 will assign tasks to worker1, worker2, and worker3.

You can watch boss1 and the workers do their jobs, approve commands to create code files, and wait for them to finish.

Result:

8. Conclusion

Combining tmux and Claude lets you create a multi-agent AI system that simulates a real company: communicating, collaborating, and automating complex workflows. Having each agent in its own session makes it easy to manage, track progress, and debug.

This system is great for AI research, testing, or even real-world workflow automation, virtual team assistants, or teamwork simulations.

If you’re interested in developing multi-agent AI systems, try deploying this model, customize roles and workflows to your needs, and feel free to contribute or suggest improvements to the original repo!

Introducing Claude 4 and Its Capabilities

Claude 4 refers to the latest generation of AI models developed by Anthropic, a company founded by former OpenAI researchers. The most powerful model in this family as of June 2024 is Claude 3.5 Opus, often informally called “Claude 4” due to its leap in performance.

Claude Opus 4 is powerful model yet and the best coding model in the world, leading on SWE-bench (72.5%) and Terminal-bench (43.2%). It delivers sustained performance on long-running tasks that require focused effort and thousands of steps, with the ability to work continuously for several hours—dramatically outperforming all Sonnet models and significantly expanding what AI agents can accomplish.

Claude Opus 4 excels at coding and complex problem-solving, powering frontier agent products. Cursor calls it state-of-the-art for coding and a leap forward in complex codebase understanding. Replit reports improved precision and dramatic advancements for complex changes across multiple files. Block calls it the first model to boost code quality during editing and debugging in its agent, codename goose, while maintaining full performance and reliability. Rakuten validated its capabilities with a demanding open-source refactor running independently for 7 hours with sustained performance. Cognition notes Opus 4 excels at solving complex challenges that other models can’t, successfully handling critical actions that previous models have missed.

Claude Sonnet 4 significantly improves on Sonnet 3.7’s industry-leading capabilities, excelling in coding with a state-of-the-art 72.7% on SWE-bench. The model balances performance and efficiency for internal and external use cases, with enhanced steerability for greater control over implementations. While not matching Opus 4 in most domains, it delivers an optimal mix of capability and practicality.

GitHub says Claude Sonnet 4 soars in agentic scenarios and will introduce it as the model powering the new coding agent in GitHub Copilot. Manus highlights its improvements in following complex instructions, clear reasoning, and aesthetic outputs. iGent reports Sonnet 4 excels at autonomous multi-feature app development, as well as substantially improved problem-solving and codebase navigation—reducing navigation errors from 20% to near zero. Sourcegraph says the model shows promise as a substantial leap in software development—staying on track longer, understanding problems more deeply, and providing more elegant code quality. Augment Code reports higher success rates, more surgical code edits, and more careful work through complex tasks, making it the top choice for their primary model.

These models advance our customers’ AI strategies across the board: Opus 4 pushes boundaries in coding, research, writing, and scientific discovery, while Sonnet 4 brings frontier performance to everyday use cases as an instant upgrade from Sonnet 3.7.

 

 


Key Strengths of Claude 4

 1. Superior Reasoning and Intelligence

Claude 4 ranks at the top in benchmark evaluations such as:

  • MMLU (Massive Multitask Language Understanding)

  • GSM8k (math problem solving)

  • HumanEval (coding)
    It rivals or exceeds OpenAI’s GPT-4-turbo and Google Gemini 1.5 Pro in complex reasoning, long-context understanding, and task execution.

 2. Massive Context Window (Up to 200K Tokens)

Claude 4 can read and reason over hundreds of pages at once, making it perfect for:

  • Analyzing lengthy legal or scientific documents

  • Comparing large codebases

  • Summarizing long texts or reports

 3. Advanced Coding Support

Claude 4 excels in:

  • Writing and explaining code in multiple languages (Python, JS, Java, etc.)

  • Debugging and understanding large code repositories

  • Pair programming and iterative development tasks

 4. Natural and Helpful Communication

  • Responses are clear, polite, and structured

  • Especially strong in creative writing, professional emails, and educational explanations

  • Can follow complex instructions and maintain context over long conversations


Safe and Aligned by Design

Claude is built with safety and alignment in mind:

  • It avoids generating harmful or unethical content

  • It is more cautious and transparent than most models

 


 How to Access or Use Claude 4

Claude is a cloud-based AI model, so you don’t install it like software — instead, you access it via the web or API.

1. Use Claude via Web App

 Steps:

  1. Go to: https://claude.ai

  2. Sign up or log in (you need a US/UK/Canada/EU phone number).

  3. Choose from free or paid plan (Claude 3.5 Opus is available only in Claude Pro – $20/month).

 Claude Pro Includes:

  • Claude 3.5 Opus (latest, most powerful)

  • Larger context

  • Priority access during high demand

 Currently, Claude is only available in select countries. If you’re outside the US/UK/Canada/EU, you may need to use a VPN and a virtual phone number to sign up (unofficial workaround).


2.  Use Claude via API (For Developers)

 API Access:

  1. Go to: https://console.anthropic.com

  2. Sign up and get an API key

  3. Use the API with tools like Python, cURL, or Postman

 Example (Python):

import anthropic

client = anthropic.Anthropic(api_key="your_api_key")

response = client.messages.create(
model="claude-3.5-opus-20240620",
max_tokens=1024,
messages=[
{"role": "user", "content": "Explain quantum computing in simple terms"}
]
)

print(response.content)


Can I Install Claude Locally?

No. Like ChatGPT or Gemini, Claude is not open-source or downloadable. It’s only available via:

 

Feature Claude 4 (Claude 3.5 Opus)
Developer Anthropic
Model Type Large Language Model (LLM)
Reasoning & Math Top-tier performance
Context Length Up to 200,000 tokens
Code Assistance Strong support for multiple languages
Language Style Human-like, calm, professional
Best Use Cases Analysis, writing, coding, dialogue
Access claude.ai or API

A Step-by-Step Guide to Integrating and Using Claude Code Action on GitHub

Investigate how Claude Code Action is great. Just create an issue and put  a mention to Claude  like @claude, Claude can write the code automatically

Introduction

In the current era of rapidly evolving technology, artificial intelligence (AI) 

stands out as one of the most significant and transformative breakthroughs on a global scale. Among the various AI-driven tools, Claude — particularly the Claude Action Code — represents a powerful integration that can be embedded into user’s GitHub repositories to address raised issues with remarkable accuracy and efficiency. This paper aims to explore the capabilities and applications of Claude Action Code in modern software development workflows.

Body content

Claude Code Action is a extension categorized as a “Action” and made available on the GitHub Marketplace by Anthropic. Users can search for and utilize it by following the provided setup instructions outlined in the README documentation. Below is a summary of the basic setup steps for integrating Claude Code Action into user’s GitHub repository: 

1.Create a workflow folder:

On GitHub: In user’s GitHub repository, click “Add file”:

insert the configuration into the path:“.git/workflows/[file_name].yml”. For instance: 

Next, insert the appropriate workflow configuration for this extension, depending on your intended use:

For example: 

name: Claude PR Assistant

on:

  issue_comment:

    types: [created]

  pull_request_review_comment:

    types: [created]

  issues:

    types: [opened, assigned]

  pull_request_review:

    types: [submitted]

 

jobs:

  claude-code-action:

    if: |

      (github.event_name == ‘issue_comment’ && 

contains(github.event.comment.body, ‘@claude’)) ||

      (github.event_name == ‘pull_request_review_comment’ && contains(github.event.comment.body, ‘@claude’)) ||

      (github.event_name == ‘pull_request_review’ && 

contains(github.event.review.body, ‘@claude’)) ||

      (github.event_name == ‘issues’ && contains(github.event.issue.body, ‘@claude’))

    runs-on: ubuntu-latest

    permissions:

      contents: write

      pull-requests: read

      issues: read

      id-token: write

    steps:

      – name: Checkout repository

        uses: actions/checkout@v4

        with:

          fetch-depth: 1

 

      – name: Run Claude PR Action

        uses: anthropics/claude-code-action@beta

        with:

          anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}

          timeout_minutes: “60”

Then, click “Commit changes” to successfully add the configuration to your repository.

On the user’s local machine: If a folder in VScode has already  been connected to the GitHub repository, the user can manually create a workflow directory and a .yml file to store the Claude configuration. Then, file can be pushed to the GitHub repository

2.API key:

  • After that, the API key should be added to the repository’s Secrets under the Setting tab, rather than being hard-coded directly into workflow file to prevent unauthorized access

 

Find Action in Secret and variables

Create a new repository secret

Add your API key to Secret’s description

Name secret as key’s name in the workflow file

✅Correct

❌Never do it

3. Using Claude Code Action

User creates a new issue within repository where Claude is intended to be used: 

The user describes the issue to be resolved – such as feature creation, bug fixing, code review, …  – in the issue’s description. You can tag “@claude” directly in the description or in a comment after the issue is created, in order trigger Claude to process the request

Ex: Ask Claude to generate complete login and registration pages based on the initial files in the repo

Claude is invoked via API to address the issue described, with the response time depending on the complexity of the request. It uses the token associated with your API key to read the issue content as well as to create or modify code within the repository

Claude’s response will appear in the comments section of the issue.

Here, Claude generates additional files, for example register.html and dashboard.html, as part of the requested implementation and show what changes are made to each file — including which parts are added, modified, or deleted.

At this point, Claude has created a separate branch in the repository containing the proposed changes. The user can then review and consider merging these updates into the main branch via a pull request.

After successfully merging into the main branch

 

Following a successful merge, the issue may be closed. At this point, Claude has been effectively utilized to generate complete, functional demo pages for user login and registration.

 

4.Result:

Registration page

Login screen

Dashboard screen

In summary, Claude Code Action proves to be a highly effective tool for streamlining development tasks, making it easier for both individuals and teams to enhance productivity.