Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Claude Code Development Configuration

Claude Code Development Configuration

Have you ever run into these situations?

All these problems can be solved with a structure called the Agent Development Kit (ADK).

Its core is just 5 folders; through them we can turn Claude Code into an automated development team with memory, discipline, division of labor, and replicability.

Overall structure:



你的项目/

├── CLAUDE.md/     ← 第一层:记忆

├── skills/        ← 第二层:知识

├── hooks/         ← 第三层:护栏

├── subagents/     ← 第四层:分工

└── plugins/       ← 第五层:复制

Level Directory / File Purpose Core meaning An Analogy
Layer 1 CLAUDE.md/ The agent's global rules and memory center Defines the AI's behavioral norms, project background, and development constraints AI project operations manual
architecture.rules Architecture rule definitions Specifies code structure, naming conventions, and directory design Technical team coding standards
global.md Globally shared memory Long-term rules that apply to all projects The AI's long-term memory
project.md Current project-specific memory The current repository's business background and special requirements An enhanced version of the project README
Layer 2 skills/ Skills module directory Inject professional capabilities into the AI The AI's skill library
SKILL.md Skill description file Tells the AI when to invoke the skill Skill manual
scripts/ Skill scripts directory Stores automation scripts and templates Toolbox
context.md Skill context Provides the background knowledge needed at skill runtime Professional knowledge base
Layer 3 hooks/ Hook system Automatically insert check logic before and after execution Automated security auditing
PreToolUse.sh Pre-tool-execution hook Validate before executing commands "Dangerous operation confirmer"
PostToolUse.sh Post-tool-execution hook Automatic handling after execution completes Automatic formatting and notifications
SessionStart.sh Session start hook Initialize the development environment IDE startup script
Layer 4 subagents/ Subagent directory Split into different specialized agents AI team collaboration system
code-reviewer.md Code review Agent Dedicated to code Review Reviewer engineer
test-runner.md Testing Agent Automatically run tests QA test engineer
explorer.md Exploratory Agent Analyze codebase structure Technical researcher
Layer 5 plugins/ Plugin system Distribute capabilities as modules AI application marketplace
manifest.json Plugin manifest Define plugin metadata npm package.json
marketplace.url Plugin marketplace address Plugin download and sharing entry point App stores
team.install Team installation script One-click sync of the team environment DevOps initialization script

Each layer solves a specific problem; let's break them down one by one.


Layer 1:CLAUDE.md — give Claude a long-term memory

What's the problem?

Claude has no cross-session memory. Tell it today to use PascalCase for component names, and it forgets when you open a new session tomorrow.

Solution

Put a CLAUDE.md file in the project and write in it everything you don't want to repeat. At the start of each session, Claude reads it automatically.

Two files, two scopes:

File location Scope
~/.claude/CLAUDE.md On your computer,All projectsall take effect
Project root directory .claude/CLAUDE.md only forthis one repositorytake effect

What to write in it? Think about what you most often repeat to Claude:

# 项目:我的电商平台



## 技术栈

- 前端:Next.js 14(App Router)

- 样式:Tailwind CSS

- 数据库:PostgreSQL + Prisma



## 命名规范

- 组件文件:大驼峰,如 `UserCard.tsx`

- 工具函数:小驼峰,如 `formatPrice.ts`

- API 路由:短横线,如 `/api/user-profile`



## Notes

- 禁止使用 `any` 类型

- 所有异步函数必须有 try/catch

- 提交代码前必须通过 ESLint 检查

- 不要直接操作 `main` 分支



## 代码风格

- 缩进:2 个空格

- 引号:单引号

- 函数优先用箭头函数

Effect: You'll never need to paste a long background introduction at the start of every conversation again.


Layer 2:skills/ — store your experience

What's the problem?

Every time you ask Claude to write a new component, it may do it differently — sometimes adding tests, sometimes not, sometimes with TypeScript types, sometimes without.

Solution

Write the standard practice as a skill file into the skills/ directory, and Claude will, based on your task description,automatically match and invokethe corresponding skill; you don't need to type any command.

Directory structure:

skills/

├── SKILL.md              ← 技能索引(描述 + 触发条件)

├── create-component.md   ← 创建 React 组件的标准流程

├── write-api.md          ← 写接口的标准流程

└── fix-bug.md            ← 排查 Bug 的标准流程

What does a skill file look like?

---

name: create-react-component

description: >

  当用户说"创建组件"、"新建页面"、"写一个 UI"时,

  自动调用此技能。

---



# Standard process for creating a React component



## 步骤

1. 检查 `src/components/` 下是否已存在同名组件

2. 用大驼峰命名新建 `.tsx` 文件

3. 必须定义 TypeScript interface,不允许 any

4. 同步在 `src/stories/` 下新建对应的 Storybook 故事

5. 在 `__tests__/` 下新建单元测试文件



## 代码模板

\`\`\`tsx

interface Props {

  // Define props here

}



export const ComponentName: React.FC = ({ }) => {

  return 
{/* 内容 */}
; }; \`\`\`

Effect: You say "help me create a user card component," and Claude automatically follows your team's standard process — tests, types, and docs, nothing missing.

💡 In plain terms: It's like writing an operations manual for a new employee; it follows the manual without you having to watch over it every time.


Layer 3:hooks/ — set an unbreakable guardrail

What's the problem?

AI sometimes performs operations you absolutely don't want — like deleting a database directly in production, or running a rm -rf command. Relying on saying "don't do that" in the prompt is unreliable for such things.

Solution

Hooks areshell scripts that run automatically before and after every Claude tool call. They're pure code logic, executed deterministically, and the AI can't bypass them.

Three core files:

hooks/

├── PreToolUse.sh    ← 工具调用「之前」运行

├── PostToolUse.sh   ← 工具调用「之后」运行

└── SessionStart.sh  ← 会话「开始时」运行

PreToolUse.sh example — intercept dangerous commands:

#!/bin/bash

# Check the command Claude is about to execute



TOOL_INPUT="$2"



# Prevent execution of rm -rf /

if echo "$TOOL_INPUT" | grep -qE "rm\s+-rf\s+/"; then

  echo "已拦截:禁止执行破坏性删除命令" >&2

  exit 1

fi



# Do not operate on production database without confirmation

if echo "$TOOL_INPUT" | grep -q "prod_db" && echo "$TOOL_INPUT" | grep -qE "DROP|DELETE"; then

  echo "已拦截:生产数据库的破坏性操作需要人工确认" >&2

  exit 1

fi



exit 0

PostToolUse.sh example — auto-format after saving files:

#!/bin/bash

# Automatically run lint and format after Claude finishes writing the file



TOOL_NAME="$1"

FILE_PATH="$2"



if [ "$TOOL_NAME" = "write_file" ]; then

  case "$FILE_PATH" in

    *.ts|*.tsx|*.js|*.jsx)

      npx eslint --fix "$FILE_PATH"

      npx prettier --write "$FILE_PATH"

      echo "已自动格式化:$FILE_PATH"

      ;;

  esac

fi

Effect:

💡 In plain terms: It's like the quality inspection step on a factory assembly line. Products must pass through it before leaving the factory; anything not up to spec is rejected outright, without relying on workers' personal judgment.


Layer 4:subagents/ — let specialists do specialized work

What's the problem?

Having Claude do "code review + run tests + write docs" all in one session makes the context grow ever larger and slower, with the various tasks interfering with each other.

Solution

Split different tasks amongindependent subagents. Each subagent has its own independent context window and dedicated tool permissions, does one thing, and reports the result when done.

Directory structure:

subagents/

├── code-reviewer.md   ← 专门做代码审查

├── test-runner.md     ← 专门跑测试

└── doc-writer.md      ← 专门写文档

code-reviewer.md example:

---

name: code-reviewer

description: PR 需要代码审查时调用此代理

tools:

  - read_file        # 只允许读文件

permissions:

  - read_only        # 只读权限,绝对不会误操作

---



# Code review agent



你是一名资深代码审查员。你只会收到 git diff,不需要了解整个项目。

你没有写入权限,只能阅读和分析。



## Review Checklist

- [ ] 有没有硬编码的密钥或密码?

- [ ] 新函数有没有对应的单元测试?

- [ ] TypeScript 类型是否明确,有没有 any?

- [ ] 异步操作有没有错误处理?

- [ ] 有没有遗留的 console.log?



## Output Format

1. **总体评价**:一句话说清楚

2. **必须修改**:阻塞合并的问题

3. **建议优化**:非阻塞的改进项

4. **结论**:可以合并 / 需要修改

Overall workflow:

你说:"帮我审查这个 PR 并运行测试"

          │

          ├──→ 调用 code-reviewer 子代理

          │         独立上下文,只看 diff,只读权限

          │         返回:结构化审查报告

          │

          ├──→ 调用 test-runner 子代理

          │         独立上下文,有执行测试的权限

          │         返回:测试通过/失败摘要

          │

          └──→ 主会话汇总结果,上下文始终保持干净

💡 In plain terms: It's like a foreman. He doesn't write code himself, but he has specialized electricians, plumbers, and carpenters under him. Each does their own job without interference, and the foreman reports overall progress at the end.


Layer 5:plugins/ — one-click replication for the whole team

What's the problem?

You spent days getting the above four layers just right, but when a new colleague joins, how do they learn this setup? Do they have to configure it all over again?

Solution

Package the whole system as a plugin; a new member runs one command and instantly has exactly the same Claude Code working environment as you.

Directory structure:

plugins/

├── manifest.json    ← 描述插件包含什么

├── marketplace.url  ← 分享链接

└── team.install     ← 一键安装脚本

team.install example:

#!/bin/bash

echo "🚀 正在安装团队 ADK 配置..."



# Install project-level CLAUDE.md

cp ./CLAUDE.md/project.md ./.claude/CLAUDE.md



# Install all skills

mkdir -p ./.claude/skills && cp -r ./skills/* ./.claude/skills/



# Install hook (remember to add execute permission)

mkdir -p ./.claude/hooks && cp -r ./hooks/* ./.claude/hooks/

chmod +x ./.claude/hooks/*.sh



# Install sub-agent

mkdir -p ./.claude/subagents && cp -r ./subagents/* ./.claude/subagents/



echo "安装完成!Claude Code 已配置为团队模式。"

A new colleague's first day on the job:

bash plugins/team.install

Done. Exactly the same Claude Code as yours.

💡 In plain terms: It's like the company's "new employee PC setup package." IT prepares an image, newcomers install with one click, and their environment is identical to veteran employees' — no manual per-person configuration.

Complete flow diagram: how the 5 layers work together

开发者输入任务

      │

      ▼

  CLAUDE.md        → 加载项目规范和背景知识

      │

      ▼

  skills/          → 匹配任务类型,调用对应工作流

      │

      ▼

  hooks/PreToolUse → 执行前检查,拦截危险操作

      │

      ▼

  subagents/       → 复杂任务拆分给专属子代理执行

      │

      ▼

  hooks/PostToolUse→ 执行后处理,自动格式化/通知

      │

      ▼

  plugins/         → 整套配置一键同步给所有团队成员

Summary of the problems solved by the 5 layers

Level folder in the window What problem it solves Analogy
Layer 1 CLAUDE.md/ Claude forgets project conventions every time Employee handbook
Layer 2 skills/ The same type of task done differently each time Operations manual
Layer 3 hooks/ Dangerous operations can't be prevented Assembly line quality inspection
Layer 4 subagents/ Context bloat for complex tasks Specialized division of labor
Layer 5 plugins/ Configuration can't be reused across the team New hire onboarding package

Quick start: 3 things you can do today

If configuring everything at once feels too complex, start with the highest-return items:

Step 1 (5 minutes): Create a CLAUDE.md, and write into it all the project background you most often repeat to Claude.

Step 2 (10 minutes): Create a hooks/PreToolUse.sh, adding a few interception rules for the dangerous commands you least want Claude to execute.

Step 3 (30 minutes): Write one of your most common task types (such as "creating a component") as your first skills/ file, accumulating your team standards.

The remaining layers can be filled in as you go; no need to do them all at once.


This system is called Agent Development Kit(ADK). Five layers of structure, one stack.

You don't need more tools, just 5 folders.