The Deska blog

CLAUDE.md and Agent Instruction Files: How to Onboard AI Agents to Your Repo

Learn how to use CLAUDE.md and agent instruction files to provide context and rules for AI coding agents within your repository workflow.

· 10 min read

Developing software with autonomous agents requires more than just a powerful model. It requires a structured way to communicate your project architecture, coding standards, and common workflows. The emergence of CLAUDE.md and agent instruction files has provided a standard pattern for onboarding AI agents to your repo efficiently. These files act as a persistent memory layer, ensuring that every time an agent enters your codebase, it follows the specific conventions you have established rather than relying on generic assumptions.

Understanding the Role of Instruction Files

An instruction file is a markdown document placed in the root of your repository. While human developers read a README.md to understand how to use a project, an AI agent reads files like CLAUDE.md or .cursorrules to understand how to build and maintain it. This distinction is critical. A README usually focuses on installation and high level features. In contrast, instruction files focus on the "how" of development: which build commands to run, how to handle errors, and which naming conventions to follow.

The primary goal is to reduce the "lost in context" problem. As codebases grow, agents can struggle to locate relevant files or remember the specific linting rules of a niche framework. By centralizing this information, you provide a roadmap that the agent can reference frequently.

Core Components of an Effective CLAUDE.md

A well structured CLAUDE.md file should be concise but comprehensive. You should include specific sections that help an agent navigate the environment without asking redundant questions.

  • Build and Test Commands: List the exact strings needed to compile the project or run unit tests.
  • Coding Style: Define preferences for quotes, semicolons, and indentation.
  • Project Architecture: Explain where the business logic resides versus the UI components.
  • Common Workflows: Describe the steps for adding a new API endpoint or a new database migration.

When these details are documented, agents can self correct. If a test fails after a code change, an agent with access to these instructions can look up the correct command to re-run the relevant test suite without human intervention.

Comparison of Agent Instruction Patterns

Different agents and environments have slightly different preferences for how they ingest instructions. While the concept remains the same, the implementation varies across the ecosystem.

File TypePrimary AudienceScopeFormatting Focus
CLAUDE.mdClaude Code / General AgentsRepository wideTechnical commands and style
.cursorrulesCursor IDEFolder or Project levelInteractive behavior and rules
.github/copilot-instructions.mdGitHub CopilotRepository wideContext for completions
AI.mdOpen Source AgentsProject levelArchitectural overview

These tools differ in approach when it comes to how strictly they follow the files. Some agents treat these files as hard constraints, while others view them as soft suggestions. It is generally best to write your instructions as imperative commands to ensure the highest level of adherence.

Integrating Instruction Files with Deska

When using a workspace like Deska, the utility of these files increases. Deska provides an infinite canvas where you can place multiple panels side by side. You can have a terminal running a coding agent, a code editor, and a notes panel all visible at once.

One effective strategy is to keep your CLAUDE.md or project rules file open in a notes or editor panel and pinned on your canvas. This allows you to visually verify the rules as the agent works. Because Deska is local-first, these instruction files reside entirely on your machine, ensuring that your architectural secrets are not stored on third party servers.

In Deska, you can run multiple agents like Claude Code and OpenCode simultaneously in separate panels. Each agent can independently read the same CLAUDE.md file. This creates a unified environment where different models follow the same set of project specific instructions, leading to consistent code output across the entire workspace.

Advanced Techniques for Prompt Engineering in Files

Simply listing commands is a good start, but advanced users leverage these files for complex logic. You can include "Golden Paths" which are step by step examples of a perfect feature implementation. If the agent sees a template for how a service should be structured, it is much more likely to replicate that pattern accurately.

Another technique is the "Anti-Pattern" list. Tell the agent explicitly what not to do. For example, if your project prohibits the use of certain libraries or requires a specific way to handle environment variables, list these as forbidden actions. This prevents the common issue of agents introducing deprecated patterns into a modern codebase.

Managing Context Overload

Providing too much information can be as detrimental as providing too little. If an instruction file is five thousand words long, the agent might lose focus on the most important rules. To prevent this, keep the main instruction file for high level rules and use subdirectories for more specific modules.

  1. Keep the root file under two hundred lines.
  2. Link to deeper documentation for specific libraries.
  3. Use clear, nested headings to help the agent scan the content.
  4. Update the file whenever you change your build tool or test runner.

If you are working on a large scale project, you can use ask-deska to help you summarize or refactor your instruction files as the repository evolves. The assistant can analyze your current session and suggest new rules based on the errors you have encountered.

FAQ: Frequently Asked Questions

How to use CLAUDE.md with Claude Code?

Claude Code automatically looks for a CLAUDE.md file in the current working directory when it starts a session. It reads this file to understand the environment. You do not need to manually feed the file to the agent, just ensure it exists in the root of your repo.

What is the difference between README.md and CLAUDE.md?

The README.md is intended for humans to understand the project purpose and installation. CLAUDE.md is specifically formatted for AI agents, focusing on technical implementation details, command syntax, and strict coding rules that help the agent operate autonomously.

Where to store AI agent rules for multiple repositories?

For repository specific rules, keep them in the root of each repo. If you have global preferences that apply to every project you work on, some developers keep a central "system prompt" file that they copy into new projects, or they use workspace specific settings in tools like Deska to apply rules across multiple panels.

Get Started with Agentic Workflows

Optimizing your repository for AI agents is an ongoing process of refining instructions. By building a solid CLAUDE.md file, you significantly reduce the friction of automated development. To see how these files work in a high productivity environment, you can download Deska today. The ability to run agents side by side while keeping your rules visible on an infinite canvas provides a superior interface for modern software engineering. If you are new to the platform, check out getting started to set up your first agentic workspace.

💡 Ideas+🐛 BugsSuggest a feature or report a bug