Claude Code Project Directory Structure
A typical Claude Code project directory structure is as follows:
your-project/
├── CLAUDE.md ← 团队共享指令,提交到 git
├── CLAUDE.local.md ← 个人覆盖,被 git 忽略
└── .claude/
├── settings.json ← 权限 + 配置,提交到 git
├── settings.local.json ← 个人权限,被 git 忽略
├── commands/ ← 自定义斜杠命令
│ ├── review.md → /project:review
│ ├── fix-issue.md → /project:fix-issue
│ └── deploy.md → /project:deploy
├── rules/ ← 模块化指令文件(全局生效)
│ ├── code-style.md
│ ├── testing.md
│ └── api-conventions.md
├── skills/ ← 自动调用的工作流
│ ├── security-review/
│ │ └── SKILL.md
│ └── deploy/
│ └── SKILL.md
└── agents/ ← 子代理角色定义
├── code-reviewer.md
└── security-auditor.md

CLAUDE.md -- project core instructions
CLAUDE.md
This is the firstfile readwhen Claude enters the project, equivalent to a project welcome manual.
CLAUDE.md is placed in the project root directory and shared by all team members; it tells Claude: what this project is, how to run it, and what conventions exist.
Typical content:
# My Project
一句话描述项目用途。
## Tech Stack
- Backend: Python / FastAPI
- Frontend: React + TypeScript
- Database: PostgreSQL
## Common Commands
\`npm run dev\` # 启动开发服务器
\`pytest tests/\` # 运行测试
\`npm run build\` # 构建生产版本
## Code Conventions
- 使用 snake_case 命名变量
- 所有 API 需要写单元测试
- PR 合并前必须通过 CI
## Architecture Overview
src/
├── api/ # FastAPI 路由层
├── services/ # 业务逻辑层
└── models/ # 数据模型层
💡 Tip: Claude automatically recursively reads CLAUDE.md in parent directories. In a monorepo, a subpackage can have its own CLAUDE.md, and Claude will merge and understand instructions from both levels.
CLAUDE.local.md
A personal exclusive overlay layered on top of CLAUDE.md.
CLAUDE.local.md stores preferences or temporary instructions relevant only to you and should not be shared with the team.
Typical content:
# 我的本地覆盖
本地数据库地址:localhost:5433(非默认端口)
调试时请优先输出详细日志。
## Temporary rules (for this task)
目前专注于重构 auth/ 模块,其他模块暂时不要改动。
.claude/settings.json -- Permission and configuration center
settings.json
Team-shared configuration file that controls whether Claude allows or forbidsperforming which operations, serving as the team security baseline.
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(pytest:*)",
"Bash(git diff:*)",
"Bash(git log:*)"
],
"deny": [
"Bash(rm -rf *)",
"Bash(curl * | bash)"
]
}
}
settings.local.json
Personal local permission override, temporarily loosening or tightening certain permissions without affecting other team members.
{
"permissions": {
"allow": [
"Bash(rm ./tmp/*)"
]
}
}
.claude/commands/ -- Custom slash commands
Each file in the directory .md is automatically mapped to a command; /project:文件名 command.
.claude/commands/ it is the core mechanism for teamsStandardizationto standardize repetitive tasks.
| File Name | Corresponding command |
|---|---|
review.md |
/project:review |
fix-issue.md |
/project:fix-issue |
deploy.md |
/project:deploy |
Example:commands/review.md
# Code Review
Please perform a complete code review on the current modifications:
1. 检查是否有安全漏洞(SQL 注入、XSS 等)
2. 验证错误处理是否完整
3. 确认测试覆盖率是否达标
4. 检查是否符合代码风格规范
5. 评估性能影响
用中文输出结构化审查报告,按严重程度排列问题。
Example:commands/fix-issue.md(with parameters)
# Fix GitHub Issue
Given Issue number $ARGUMENTS, please:
1. 读取并理解 Issue 描述
2. 定位相关代码文件
3. 实现最小化修复方案
4. 编写对应的单元测试
5. 更新 CHANGELOG.md
调用方式:/project:fix-issue 123
💡 Parameter passing: Command files can use
$ARGUMENTSplaceholders to receive parameters passed in during invocation.
.claude/rules/ -- Modular behavior rules
Split the rules in CLAUDE.mdinto modulesfor storage; Claude follows them throughout the session. Suitable for long-term stable behavioral conventions, avoiding an overly bloated CLAUDE.md.
Example:rules/code-style.md
# Code Style Rules
- TypeScript 严格模式,禁用 any 类型
- 函数长度不超过 40 行,超出则拆分
- 优先使用 const,避免使用 let
- 导入顺序:标准库 → 三方包 → 本地模块
- 所有 export 的函数/类型需要 JSDoc 注释
- 禁止使用 console.log,使用项目 logger
Example:rules/testing.md
# Code Style Rules
- TypeScript 严格模式,禁用 any 类型
- 函数长度不超过 40 行,超出则拆分
- 优先使用 const,避免使用 let
- 导入顺序:标准库 → 三方包 → 本地模块
- 所有 export 的函数/类型需要 JSDoc 注释
- 禁止使用 console.log,使用项目 logger
Example:rules/api-conventions.md
# API Conventions
- RESTful 风格,资源名使用复数形式
- 统一响应格式:{ data, error, meta }
- 错误码遵循 HTTP 标准语义
- 所有接口需要在 OpenAPI 文档中声明
- 分页参数统一使用 page / page_size
.claude/skills/ -- Automatically invoked workflows
Skills are more advancedcomposite workflows. When Claude determines that a task suits a certain skill, it automatically reads and executes the corresponding SKILL.md,without manual invocation。
Each skill is a subdirectory containing SKILL.md。
Example:skills/security-review/SKILL.md
# Security Review Skill
## Trigger conditions
当用户请求代码审查、代码涉及认证/授权/加密/用户输入处理时自动触发。
## Execution Steps
1. 扫描 SQL 注入风险(检查所有数据库查询)
2. 检查 XSS 防护(验证输出转义)
3. 审计权限边界(确认最小权限原则)
4. 检查敏感数据处理(日志、错误信息中是否泄露)
5. 输出 OWASP Top 10 对照检查表
## Output Format
按 CVSS 评分排列,高危问题优先展示。
⚡ The difference between Skills and Commands:
.claude/agents/ -- Sub-agent roles
Defines specialized sub-agents that can bedispatched by the main Claude instance. In complex tasks, the main agent delegates subtasks to corresponding expert roles, achievingmulti-agent collaboration. Sub-agents run in isolated contexts with independent permission scopes.
Example:agents/code-reviewer.md
---
name: code-reviewer
description: 资深代码审查员,专注代码质量与可维护性
---
# Code Reviewer
## Role Definition
你是一名拥有 10 年经验的资深工程师,专注于代码可读性、性能优化和最佳实践。
## Key Review Points
- 命名是否清晰表达意图
- 函数/类的单一职责原则
- 边界条件和错误处理
- 性能瓶颈(N+1 查询、不必要的循环等)
## 权限
只读访问,不直接修改文件。
## Output Format
使用 Markdown 表格输出,包含:问题位置、严重程度、建议方案。
Example:agents/security-auditor.md
---
name: security-auditor
description: 安全审计专家,专注漏洞扫描与合规审计
---
# Security Auditor
## Role Definition
你是一名安全工程师,熟悉 OWASP、CVE 数据库和常见攻击向量。
## Audit Scope
- 认证与授权逻辑
- 输入验证与输出转义
- 依赖包已知漏洞(结合 npm audit / pip audit)
- 敏感信息泄露风险
## 权限
只读访问 + 可运行安全扫描工具。
## Output Format
按 CVSS 3.1 评分排列,包含:漏洞描述、影响范围、修复建议、参考链接。
Quick reference table
| File / Directory | Commit to Git | Trigger Method | Core use |
|---|---|---|---|
CLAUDE.md |
✅ Yes | Automatic (at startup) | Project base instructions and conventions |
CLAUDE.local.md |
❌ No | Automatic (at startup) | Personal override, temporary instructions |
.claude/settings.json |
✅ Yes | Automatic (at startup) | Team permission baseline |
.claude/settings.local.json |
❌ No | Automatic (at startup) | Personal permission override |
.claude/commands/*.md |
✅ Yes | Manual (/project:xxx) |
Reusable standardized workflows |
.claude/rules/*.md |
✅ Yes | Automatic (globally effective) | Modular behavior specifications |
.claude/skills/*/SKILL.md |
✅ Yes | Automatic (Claude determines) | Intelligent composite workflows |
.claude/agents/*.md |
✅ Yes | Automatic (main agent dispatch) | Professional sub-agent role definitions |

Best Practice Recommendations
Start with the minimum viable configuration:
your-project/
├── CLAUDE.md # 先从这里开始
└── .claude/
└── settings.json # 配置基本权限
As the project develops, gradually introduce:
commands/— When you find yourself repeatedly entering the same instructionsrules/— When CLAUDE.md exceeds 100 lines, split into modulesskills/— When complex multi-step workflows need standardizationagents/— When tasks are complex enough to require multiple professional perspectives in parallel
Principle: "Good enough" beats "perfect". Don't build a complex multi-agent system from the start; introduce it when truly needed.