Claude Code Mastery
Claude Code 精通指南
Expert-level skill for mastering Claude Code CLI -- from CLAUDE.md optimization and
skill authoring to subagent creation, hooks automation, and context engineering.
精通Claude Code CLI的高阶技能——从CLAUDE.md优化、Skill创作到子Agent创建、Hooks自动化及上下文工程全覆盖。
claude-code, claude-cli, CLAUDE.md, skill-authoring, subagents, hooks,
context-window, token-budget, MCP-servers, worktrees, permission-modes,
prompt-engineering, context-engineering, progressive-disclosure, slash-commands
claude-code, claude-cli, CLAUDE.md, skill-authoring, subagents, hooks,
context-window, token-budget, MCP-servers, worktrees, permission-modes,
prompt-engineering, context-engineering, progressive-disclosure, slash-commands
Scaffold a new skill package with proper structure
搭建结构规范的新Skill包脚手架
python scripts/skill_scaffolder.py my-new-skill --domain engineering --description "Brief description"
python scripts/skill_scaffolder.py my-new-skill --domain engineering --description "简要描述"
Analyze and optimize an existing CLAUDE.md
分析并优化现有CLAUDE.md
python scripts/claudemd_optimizer.py path/to/CLAUDE.md
python scripts/claudemd_optimizer.py path/to/CLAUDE.md
Estimate context window usage across a project
估算项目整体上下文窗口使用情况
python scripts/context_analyzer.py /path/to/project
python scripts/context_analyzer.py /path/to/project
All tools support JSON output
所有工具均支持JSON格式输出
python scripts/claudemd_optimizer.py CLAUDE.md --json
python scripts/context_analyzer.py . --json --max-depth 3
python scripts/claudemd_optimizer.py CLAUDE.md --json
python scripts/context_analyzer.py . --json --max-depth 3
1. Skill Scaffolder
1. Skill脚手架工具
Generates a complete skill directory with SKILL.md template, scripts/, references/,
assets/ directories, and properly formatted YAML frontmatter.
bash
python scripts/skill_scaffolder.py my-skill --domain engineering --description "Does X"
python scripts/skill_scaffolder.py my-skill -d marketing --description "Campaign tools" --json
python scripts/skill_scaffolder.py my-skill -d product --description "User research" -o /path/
| Parameter | Description |
|---|
| Name for the skill (kebab-case recommended) |
| Domain category (engineering, marketing, product, etc.) |
| Brief description for YAML frontmatter |
| Semantic version (default: 1.0.0) |
| License type (default: MIT) |
| Skill category for metadata |
| Parent directory for skill folder |
| Output results as JSON |
生成完整的Skill目录结构,包含SKILL.md模板、scripts/、references/、assets/目录,以及格式规范的YAML前置元数据。
bash
python scripts/skill_scaffolder.py my-skill --domain engineering --description "实现X功能"
python scripts/skill_scaffolder.py my-skill -d marketing --description "营销工具" --json
python scripts/skill_scaffolder.py my-skill -d product --description "用户研究" -o /path/
| 参数 | 说明 |
|---|
| Skill名称(推荐使用短横线分隔格式) |
| 领域分类(engineering、marketing、product等) |
| YAML前置元数据中的简要描述 |
| 语义化版本(默认:1.0.0) |
| 许可证类型(默认:MIT) |
| Skill元数据分类 |
| Skill文件夹的父目录 |
| 以JSON格式输出结果 |
2. CLAUDE.md Optimizer
2. CLAUDE.md优化工具
Analyzes a CLAUDE.md file and produces actionable optimization recommendations.
bash
python scripts/claudemd_optimizer.py CLAUDE.md
python scripts/claudemd_optimizer.py CLAUDE.md --token-limit 4000 --json
| Parameter | Description |
|---|
| Path to the CLAUDE.md file to analyze |
| Maximum recommended token count (default: 6000) |
| Output results as JSON |
Report includes: line count, token estimate, section completeness, redundancy
detection, missing sections, hierarchical loading suggestions, scored recommendations.
分析CLAUDE.md文件并提供可落地的优化建议。
bash
python scripts/claudemd_optimizer.py CLAUDE.md
python scripts/claudemd_optimizer.py CLAUDE.md --token-limit 4000 --json
| 参数 | 说明 |
|---|
| 待分析的CLAUDE.md文件路径 |
| 建议的最大Token数量(默认:6000) |
| 以JSON格式输出结果 |
**报告包含:**行数统计、Token估算、章节完整性检查、冗余内容检测、缺失章节提示、分层加载建议、带评分的优化方案。
3. Context Analyzer
3. 上下文分析工具
Scans a project to estimate context window consumption by file category.
bash
python scripts/context_analyzer.py .
python scripts/context_analyzer.py /path/to/project --max-depth 4 --json
python scripts/context_analyzer.py . --context-window 200000
| Parameter | Description |
|---|
| Path to the project directory |
| Maximum directory traversal depth (default: 5) |
| Total context window size in tokens (default: 200000) |
| Output results as JSON |
Report includes: token estimates per category, percentage of context consumed,
largest files, budget breakdown, reduction recommendations.
扫描项目,按文件类别估算上下文窗口消耗情况。
bash
python scripts/context_analyzer.py .
python scripts/context_analyzer.py /path/to/project --max-depth 4 --json
python scripts/context_analyzer.py . --context-window 200000
| 参数 | 说明 |
|---|
| 项目目录路径 |
| 目录遍历的最大深度(默认:5) |
| 上下文窗口总Token容量(默认:200000) |
| 以JSON格式输出结果 |
**报告包含:**各分类的Token估算、上下文占用百分比、最大文件列表、预算分配明细、缩减建议。
Workflow 1: CLAUDE.md Optimization
工作流1:CLAUDE.md 优化
Step 1: Audit --
python scripts/claudemd_optimizer.py CLAUDE.md
Step 2: Follow the recommended structure:
步骤1:审计 --
python scripts/claudemd_optimizer.py CLAUDE.md
步骤2:遵循推荐结构:
Project Purpose -- What the project is, who it serves
项目目标 -- 项目定位与服务对象
Architecture Overview -- Directory structure, key patterns
架构概览 -- 目录结构、核心模式
Development Environment -- Build commands, test commands, setup
开发环境 -- 构建命令、测试命令、环境搭建
Key Principles -- 3-7 non-obvious rules Claude must follow
核心原则 -- Claude必须遵循的3-7条非显式规则
Anti-Patterns to Avoid -- Things that look reasonable but are wrong
避坑指南 -- 看似合理但实际错误的做法
Git Workflow -- Branch strategy, commit conventions
Git工作流 -- 分支策略、提交规范
**Step 3: Apply token-saving patterns:**
- Bullet points over paragraphs (30% fewer tokens)
- Code blocks for commands (prevents misinterpretation)
- Remove generic advice Claude already knows
- Move domain details to child CLAUDE.md files
**Step 4: Set up hierarchical loading:**
project/
├── CLAUDE.md # Global: purpose, architecture, principles
├── frontend/CLAUDE.md # Frontend-specific: React patterns, styling
├── backend/CLAUDE.md # Backend-specific: API patterns, DB conventions
└── .claude/CLAUDE.md # User-specific overrides (gitignored)
**Step 5: Validate** -- `python scripts/claudemd_optimizer.py CLAUDE.md --token-limit 4000`
**步骤3:应用Token节省技巧:**
- 使用 bullet 点代替段落(减少30% Token)
- 用代码块展示命令(避免误解)
- 删除Claude已掌握的通用建议
- 将领域细节移至子CLAUDE.md文件
**步骤4:设置分层加载:**
project/
├── CLAUDE.md # 全局:目标、架构、原则
├── frontend/CLAUDE.md # 前端专属:React模式、样式规范
├── backend/CLAUDE.md # 后端专属:API模式、数据库约定
└── .claude/CLAUDE.md # 用户自定义配置(已加入git忽略)
**步骤5:验证** -- `python scripts/claudemd_optimizer.py CLAUDE.md --token-limit 4000`
Workflow 2: Skill Authoring
工作流2:Skill 创作
Step 1: Scaffold --
python scripts/skill_scaffolder.py my-skill -d engineering --description "..."
Step 2: Write the SKILL.md following this order:
- YAML frontmatter (name, description with trigger phrases, license, metadata)
- Title and one-line summary
- Table of contents
- Quick Start (3-5 copy-pasteable commands)
- Tools Overview (each script with usage, parameters table)
- Workflows (step-by-step sequences combining tools and knowledge)
- Reference Documentation (links to references/)
- Quick Reference (tables, cheat sheets)
Step 3: Optimize the description for auto-discovery:
yaml
description: >-
This skill should be used when the user asks to "analyze performance",
"optimize queries", "profile memory", or "benchmark endpoints".
Use for performance engineering and capacity planning.
Step 4: Build Python tools -- standard library only, argparse, --json flag,
module docstring, error handling. See references/skill-authoring-guide.md.
步骤1:搭建脚手架 --
python scripts/skill_scaffolder.py my-skill -d engineering --description "..."
步骤2:按以下顺序编写SKILL.md:
- YAML前置元数据(名称、包含触发短语的描述、许可证、元数据)
- 标题与单行摘要
- 目录
- 快速开始(3-5个可直接复制粘贴的命令)
- 工具概览(每个脚本的用法、参数表格)
- 工作流(结合工具与知识的分步流程)
- 参考文档(指向references/的链接)
- 速查表(表格、 cheat sheet)
步骤3:优化描述以支持自动发现:
yaml
description: >-
当用户要求“分析性能”、“优化查询”、“内存分析”或“端点基准测试”时,应使用本技能。
适用于性能工程与容量规划。
步骤4:开发Python工具 -- 仅使用标准库、argparse、--json flag、模块文档字符串、错误处理。详见references/skill-authoring-guide.md。
Workflow 3: Subagent Creation
工作流3:子Agent 创建
Step 1: Define a narrow scope (one thing done well).
Step 2: Create
.claude/agents/agent-name.yaml
:
yaml
---
name: security-reviewer
description: Reviews code for security vulnerabilities and compliance
model: claude-sonnet-4-20250514
allowed-tools:
- Read
- Glob
- Grep
- Bash(git diff*)
custom-instructions: |
You are a security-focused code reviewer. For every change:
1. Check for hardcoded secrets
2. Identify injection vulnerabilities
3. Verify auth patterns
4. Flag insecure dependencies
Output a structured report with severity levels.
---
Step 3: Configure tool access -- read-only (
), read+commands
(
), or write-capable (
).
Step 4: Invoke --
/agents/security-reviewer Review the last 3 commits
See references/subagent-patterns.md for delegation
patterns, memory persistence, and production recipes.
步骤1:定义窄范围职责(专注做好一件事)。
步骤2:创建 .claude/agents/agent-name.yaml
:
yaml
---
name: security-reviewer
description: 审查代码中的安全漏洞与合规性问题
model: claude-sonnet-4-20250514
allowed-tools:
- Read
- Glob
- Grep
- Bash(git diff*)
custom-instructions: |
你是专注于安全的代码审查员。对于每一处变更:
1. 检查硬编码密钥
2. 识别注入漏洞
3. 验证认证模式
4. 标记不安全依赖
输出包含严重级别的结构化报告。
---
步骤3:配置工具权限 -- 只读(
)、可读可执行(
)、可写(
)。
步骤4:调用 --
/agents/security-reviewer 审查最近3次提交
详见references/subagent-patterns.md中的委托模式、内存持久化及生产级实践方案。
Workflow 4: Hooks Setup
工作流4:Hooks 配置
Hooks run custom scripts at lifecycle events without user approval.
| Hook | Fires When | Blocking |
|---|
| Before tool executes | Yes (exit 1 blocks) |
| After tool completes | No |
| Claude sends notification | No |
| Claude finishes turn | No |
| Session/compact begins | No |
json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true" }]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "bash .claude/hooks/validate.sh" }]
}
]
}
}
See references/hooks-cookbook.md for 25+ ready-to-use recipes.
Hooks会在生命周期事件中自动运行自定义脚本,无需用户手动批准。
| Hook 类型 | 触发时机 | 是否阻塞 |
|---|
| 工具执行前 | 是(返回1会阻塞执行) |
| 工具执行完成后 | 否 |
| Claude发送通知时 | 否 |
| Claude完成当前轮次交互时 | 否 |
| 会话/压缩模式启动时 | 否 |
json
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [{ "type": "command", "command": "prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true" }]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [{ "type": "command", "command": "bash .claude/hooks/validate.sh" }]
}
]
}
}
详见references/hooks-cookbook.md中的25+个即用型实践方案。
Workflow 5: Context Management
工作流5:上下文管理
Step 1: Audit --
python scripts/context_analyzer.py /path/to/project
Step 2: Apply the context budget framework:
| Category | Budget | Purpose |
|---|
| System prompt + CLAUDE.md | 5-10% | Project configuration |
| Skill definitions | 5-15% | Active skill content |
| Source code (read files) | 30-50% | Files Claude reads |
| Conversation history | 20-30% | Messages and responses |
| Working memory | 10-20% | Reasoning space |
Step 3: Reduce overhead:
- Keep root CLAUDE.md under 4000 tokens
- Use hierarchical loading (child CLAUDE.md files load on demand)
- Avoid reading entire large files -- use line ranges
- Use proactively after completing subtasks
- Start new sessions for unrelated tasks
步骤1:审计 --
python scripts/context_analyzer.py /path/to/project
步骤2:应用上下文预算框架:
| 分类 | 预算占比 | 用途 |
|---|
| 系统提示 + CLAUDE.md | 5-10% | 项目配置 |
| Skill定义 | 5-15% | 活跃Skill内容 |
| 源代码(读取文件) | 30-50% | Claude读取的文件 |
| 对话历史 | 20-30% | 消息与回复 |
| 工作内存 | 10-20% | 推理空间 |
步骤3:减少开销:
- 根目录CLAUDE.md控制在4000 Token以内
- 使用分层加载(子CLAUDE.md文件按需加载)
- 避免读取完整大文件——使用行范围读取
- 完成子任务后主动使用命令
- 针对无关任务启动新会话
Workflow 6: Prompt Engineering for Claude Code
工作流6:Claude Code 提示词工程
Weak: Fix the bug in the login flow
弱提示:修复登录流中的bug
Strong: Fix the auth bug in src/auth/login.ts where expired refresh tokens
强提示:修复src/auth/login.ts中过期刷新令牌导致5xx错误的认证bug。在第45行的try/catch中捕获TokenExpiredError。
cause a 500 error. Catch TokenExpiredError in the try/catch on line 45.
**Specify output format:**
Create .claude/settings.json with hooks that:
- Auto-format TypeScript with prettier after Edit/Write
- Block Bash commands containing "rm -rf"
- Log all tool uses to /tmp/claude-session.log
**Use checkpoints for multi-step work:**
Implement the dashboard. After each step, wait for confirmation:
- Create route at src/app/dashboard/page.tsx
- Build DashboardLayout component
- Add API endpoint at src/app/api/dashboard/route.ts
- Write tests in tests/dashboard.test.tsx
**Leverage Claude Code's strengths:** point it at existing code, ask it to follow
established patterns, give it test cases, let it search before changing.
---
创建.claude/settings.json配置Hooks,实现:
- 执行Edit/Write操作后自动用prettier格式化TypeScript代码
- 阻止包含"rm -rf"的Bash命令
- 将所有工具使用日志记录到/tmp/claude-session.log
实现仪表盘功能。完成每一步后等待确认:
- 在src/app/dashboard/page.tsx创建路由
- 构建DashboardLayout组件
- 在src/app/api/dashboard/route.ts添加API端点
- 在__tests__/dashboard.test.tsx编写测试用例
**发挥Claude Code优势:** 指向现有代码、要求遵循已建立的模式、提供测试用例、先搜索再修改。
---
Worktrees for Parallel Work
并行工作的工作树
/worktree feature/new-api # Creates isolated working copy
Useful for exploring alternatives, parallel tasks, and risky refactors.
bash
git worktree add .claude/worktrees/feature-api feature/new-api
git worktree list
git worktree remove .claude/worktrees/feature-api
/worktree feature/new-api # 创建独立的工作副本
适用于探索替代方案、并行任务及高风险重构。
bash
git worktree add .claude/worktrees/feature-api feature/new-api
git worktree list
git worktree remove .claude/worktrees/feature-api
| Mode | Behavior | Best For |
|---|
| Default | Asks permission for writes | Normal development |
| Allowlist | Auto-approves listed tools | Repetitive workflows |
| Yolo | Auto-approves everything | Trusted automation |
json
{ "permissions": { "allow": ["Read", "Glob", "Grep", "Bash(npm test*)"],
"deny": ["Bash(rm -rf*)", "Bash(git push*)"] } }
| 模式 | 行为 | 适用场景 |
|---|
| 默认模式 | 写入操作需用户批准 | 常规开发 |
| 白名单模式 | 自动批准列表中的工具 | 重复性工作流 |
| Yolo模式 | 自动批准所有操作 | 可信自动化场景 |
json
{ "permissions": { "allow": ["Read", "Glob", "Grep", "Bash(npm test*)"],
"deny": ["Bash(rm -rf*)", "Bash(git push*)"] } }
MCP Server Integration
MCP服务器集成
| Server | Purpose |
|---|
| File access beyond project |
| GitHub API (issues, PRs) |
| Database queries |
| Persistent key-value store |
| Web search |
| Browser automation |
| 服务器 | 用途 |
|---|
| 访问项目外的文件系统 |
| GitHub API(issues、PRs) |
| 数据库查询 |
| 持久化键值存储 |
| 网页搜索 |
| 浏览器自动化 |
Memory and Session Management
内存与会话管理
- CLAUDE.md -- Project-level memory, loads every session
- Session handoff -- Ask Claude to write
- MCP memory server -- Structured persistent memory across sessions
- -- Summarize conversation to free context
- CLAUDE.md -- 项目级内存,每次会话都会加载
- 会话交接 -- 要求Claude写入
- MCP内存服务器 -- 跨会话的结构化持久化内存
- -- 总结对话以释放上下文空间
Progressive Disclosure
渐进式披露
- Root CLAUDE.md -- Project-wide rules only (under 200 lines)
- Domain CLAUDE.md files -- ,
- Skill files -- Loaded when relevant skills trigger
- Reference files -- Deep knowledge loaded on explicit request
Rule: If Claude does not need it for every task, move it out of root CLAUDE.md.
- 根目录CLAUDE.md -- 仅包含项目全局规则(200行以内)
- 领域CLAUDE.md文件 -- ,
- Skill文件 -- 相关Skill触发时加载
- 参考文件 -- 深度知识仅在显式请求时加载
规则: 如果Claude并非每个任务都需要某部分内容,就将其移出根目录CLAUDE.md。
Token Budget Management
Token预算管理
- 1 token is approximately 3.5 characters for Claude models
- A 200-line CLAUDE.md is roughly 2000-3000 tokens
200K context window:
├── System prompt: ~3K tokens (fixed)
├── CLAUDE.md tree: ~5K tokens (target)
├── Active skills: ~10K tokens (on demand)
├── Source files: ~80K tokens (the work)
├── Conversation: ~70K tokens (grows)
└── Headroom: ~32K tokens (reasoning)
- 对于Claude模型,1个Token约等于3.5个字符
- 200行的CLAUDE.md约占200-3000个Token
20万Token上下文窗口分配:
├── 系统提示: ~3K Token(固定)
├── CLAUDE.md树: ~5K Token(目标值)
├── 活跃Skills: ~10K Token(按需加载)
├── 源文件: ~80K Token(核心工作内容)
├── 对话历史: ~70K Token(持续增长)
└── 预留空间: ~32K Token(推理使用)
Include: non-obvious conventions, technology versions, test/deploy commands,
architecture decisions and rationale.
Exclude: generic programming advice, language syntax Claude knows, verbose
paragraphs replaceable by bullets, historical information irrelevant to current work.
Test: Ask Claude to do a common task. If it makes preventable mistakes, update
CLAUDE.md. If it succeeds without reading a section, that section may be unnecessary.
需包含: 非显式约定、技术版本、测试/部署命令、架构决策及理由。
需排除: 通用编程建议、Claude已掌握的语言语法、可被bullet点替代的冗长段落、与当前工作无关的历史信息。
测试方法: 让Claude完成常见任务。如果它犯了可预防的错误,就更新CLAUDE.md。如果它无需读取某部分内容就能成功完成任务,那该部分可能是多余的。
Editor and Agent Integration
编辑器与Agent集成
Claude Code with VS Code / Cursor
Claude Code 与 VS Code / Cursor
- VS Code: Claude Code in terminal + Copilot for inline completions
- Cursor: Cursor Tab/Cmd+K for inline edits, Claude Code for multi-file work
- Exclude from VS Code search:
"search.exclude": {".claude": true}
- VS Code:终端中使用Claude Code + Copilot实现行内补全
- Cursor:使用Tab/Cmd+K进行行内编辑,Claude Code处理多文件工作
- 在VS Code搜索中排除目录:
"search.exclude": {".claude": true}
Claude Code vs Codex CLI
Claude Code vs Codex CLI
| Feature | Claude Code | Codex CLI |
|---|
| Context awareness | CLAUDE.md hierarchy | Single prompt |
| Tool ecosystem | MCP servers | Function calling |
| Permission model | Granular allowlists | Sandbox only |
| Session memory | Conversation + compact | Stateless |
| Subagents | Built-in agent system | Not available |
| 特性 | Claude Code | Codex CLI |
|---|
| 上下文感知 | CLAUDE.md分层结构 | 单一提示词 |
| 工具生态 | MCP服务器 | 函数调用 |
| 权限模型 | 细粒度白名单 | 仅沙箱环境 |
| 会话内存 | 对话历史+压缩 | 无状态 |
| 子Agent | 内置Agent系统 | 不支持 |
Programmatic Invocation
程序化调用
bash
echo "Explain this project" | claude --print
claude --print "Run tests and summarize failures"
claude --model claude-sonnet-4-20250514 --print "Quick review of last commit"
bash
echo "解释这个项目" | claude --print
claude --print "运行测试并总结失败案例"
claude --model claude-sonnet-4-20250514 --print "快速审查最近一次提交"
Reference Documentation
参考文档
| Document | Path | Description |
|---|
| Skill Authoring Guide | references/skill-authoring-guide.md | Complete skill writing reference |
| Subagent Patterns | references/subagent-patterns.md | Agent creation, delegation, recipes |
| Hooks Cookbook | references/hooks-cookbook.md | 25+ practical hook recipes |
| 文档 | 路径 | 说明 |
|---|
| Skill创作指南 | references/skill-authoring-guide.md | 完整的Skill编写参考 |
| 子Agent模式 | references/subagent-patterns.md | Agent创建、委托模式及实践方案 |
| Hooks实践手册 | references/hooks-cookbook.md | 25+个实用Hooks方案 |
| Template | Path | Description |
|---|
| Skill Template | assets/skill-template.md | Ready-to-use SKILL.md template |
| Agent Template | assets/agent-template.md | Ready-to-use subagent definition |
| 模板 | 路径 | 说明 |
|---|
| Skill模板 | assets/skill-template.md | 即用型SKILL.md模板 |
| Agent模板 | assets/agent-template.md | 即用型子Agent定义模板 |
Quick Reference Tables
速查表
| Command | Description |
|---|
| Show available commands |
| Summarize conversation to free context |
| Clear conversation history |
| Switch model mid-session |
| List and invoke custom agents |
| View and modify tool permissions |
| Open settings |
| Show token usage and cost |
| Diagnose configuration issues |
| Generate CLAUDE.md for current project |
| 命令 | 说明 |
|---|
| 显示可用命令 |
| 总结对话以释放上下文空间 |
| 清除对话历史 |
| 会话中切换模型 |
| 列出并调用自定义Agent |
| 查看并修改工具权限 |
| 打开设置界面 |
| 显示Token使用量及成本 |
| 诊断配置问题 |
| 为当前项目生成CLAUDE.md |
CLAUDE.md Loading Order
CLAUDE.md 加载顺序
- -- user global, always loaded
- -- project root, always loaded
/project/.claude/CLAUDE.md
-- project config, always loaded
/project/subdir/CLAUDE.md
-- subdirectory, loaded when files accessed
- -- 用户全局配置始终加载
- -- 项目根目录配置始终加载
/project/.claude/CLAUDE.md
-- 项目配置始终加载
/project/subdir/CLAUDE.md
-- 子目录配置,访问该目录文件时加载
Settings.json Structure
Settings.json 结构
json
{
"permissions": { "allow": ["Tool(pattern*)"], "deny": ["Tool(pattern*)"] },
"hooks": {
"PreToolUse": [{ "matcher": "regex", "hooks": [{ "type": "command", "command": "script" }] }],
"PostToolUse": [{ "matcher": "regex", "hooks": [{ "type": "command", "command": "script" }] }]
},
"mcpServers": { "name": { "command": "cmd", "args": [], "env": {} } }
}
Last Updated: February 2026
Version: 1.0.0
Tools: 3 Python CLI tools
References: 3 deep-dive guides
Templates: 2 ready-to-use templates
json
{
"permissions": { "allow": ["Tool(pattern*)"], "deny": ["Tool(pattern*)"] },
"hooks": {
"PreToolUse": [{ "matcher": "regex", "hooks": [{ "type": "command", "command": "script" }] }],
"PostToolUse": [{ "matcher": "regex", "hooks": [{ "type": "command", "command": "script" }] }]
},
"mcpServers": { "name": { "command": "cmd", "args": [], "env": {} } }
}
最后更新: 2026年2月
版本: 1.0.0
工具: 3个Python CLI工具
参考文档: 3份深度指南
模板: 2个即用型模板