context-master

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Context Master

上下文管理大师

🚨 CRITICAL GUIDELINES

🚨 关键准则

Windows File Path Requirements

Windows文件路径要求

MANDATORY: Always Use Backslashes on Windows for File Paths
When using Edit or Write tools on Windows, you MUST use backslashes (
\
) in file paths, NOT forward slashes (
/
).
Examples:
  • ❌ WRONG:
    D:/repos/project/file.tsx
  • ✅ CORRECT:
    D:\repos\project\file.tsx
This applies to:
  • Edit tool file_path parameter
  • Write tool file_path parameter
  • All file operations on Windows systems
【强制要求:Windows系统下文件路径必须使用反斜杠】
在Windows系统上使用编辑或写入工具时,文件路径必须使用反斜杠(
\
),而不能使用正斜杠(
/
)。
示例:
  • ❌ 错误:
    D:/repos/project/file.tsx
  • ✅ 正确:
    D:\repos\project\file.tsx
此要求适用于:
  • Edit工具的file_path参数
  • Write工具的file_path参数
  • Windows系统上的所有文件操作

Documentation Guidelines

文档编写准则

NEVER create new documentation files unless explicitly requested by the user.
  • Priority: Update existing README.md files rather than creating new documentation
  • Repository cleanliness: Keep repository root clean - only README.md unless user requests otherwise
  • Style: Documentation should be concise, direct, and professional - avoid AI-generated tone
  • User preference: Only create additional .md files when user specifically asks for documentation

Universal context management and planning system for complex tasks, long coding sessions, and efficient workflow optimization.

除非用户明确要求,否则绝不要创建新的文档文件。
  • 优先级:优先更新现有的README.md文件,而非创建新文档
  • 仓库整洁性:保持仓库根目录整洁 - 除非用户要求,否则只保留README.md
  • 风格:文档应简洁、直接、专业 - 避免AI生成式的冗余语气
  • 用户偏好:仅当用户明确要求文档时,才创建额外的.md文件

适用于复杂任务、长时间编码会话和高效工作流优化的通用上下文管理与规划系统。

⚡ TL;DR QUICK START (Read This First)

⚡ 快速入门(请先阅读此部分)

For ANY multi-file project, follow these 5 steps:
1️⃣ STOP - Don't create files yet
2️⃣ PLAN - Use "think hard" OR create planning document
3️⃣ ANNOUNCE - Tell user your file creation order
4️⃣ CREATE - Make files in optimal order (dependencies first)
5️⃣ VERIFY - Check all references work
Example:
User: "Create a portfolio with home, about, projects pages"

✓ Step 1: STOP [Don't immediately create index.html]
✓ Step 2: PLAN [Think: Need styles.css + 3 HTML files, CSS first]
✓ Step 3: ANNOUNCE ["I'll create: 1. styles.css, 2. index.html, 3. about.html, 4. projects.html"]
✓ Step 4: CREATE [Make them in that order]
✓ Step 5: VERIFY [Check all HTML files link to styles.css correctly]

Result: Done efficiently, no refactoring needed!
Token savings: ~5,000 tokens (62%) vs doing it wrong
Continue reading below for detailed guidance...

对于任何多文件项目,请遵循以下5个步骤:
1️⃣ 暂停 - 先不要创建文件
2️⃣ 规划 - 使用"深度思考"或创建规划文档
3️⃣ 告知 - 向用户说明你的文件创建顺序
4️⃣ 创建 - 按最优顺序创建文件(先创建依赖项)
5️⃣ 验证 - 检查所有引用是否正常工作
示例:
用户:"创建一个包含主页、关于页、项目页的作品集网站"

✓ 步骤1:暂停 [不要立即创建index.html]
✓ 步骤2:规划 [思考:需要styles.css + 3个HTML文件,应先创建CSS]
✓ 步骤3:告知 ["我将按以下顺序创建文件:1. styles.css, 2. index.html, 3. about.html, 4. projects.html"]
✓ 步骤4:创建 [按上述顺序创建文件]
✓ 步骤5:验证 [检查所有HTML文件是否正确链接到styles.css]

结果:高效完成,无需重构!
令牌节省:与错误方式相比,可节省约5000个令牌(62%)
继续阅读下文获取详细指导...

Overview

概述

This skill provides comprehensive context management, planning strategies, and workflow optimization for ANY complex coding task, not just multi-file projects.
MUST use this skill for:
  • ✅ ANY complex task requiring planning or strategy
  • ✅ Multi-file projects (HTML, CSS, JS, APIs, apps, docs)
  • ✅ Architecture or design decisions
  • ✅ Research tasks requiring analysis
  • ✅ Refactoring work
  • ✅ Long coding sessions (context optimization)
  • ✅ Tasks with 3+ sequential steps
What this skill provides:
  • Optimal file creation order - Which files to create first, dependency management
  • Context-efficient workflows - 62% average context savings
  • Extended thinking delegation - 23x context efficiency for deep analysis
  • Passive deep thinking architecture - Get analytical depth without context cost
  • Progressive task decomposition - Break complex tasks into manageable phases
  • Planning frameworks - Think before coding, prevent redundant work
  • Session optimization - Maintain performance in long interactions
This skill activates automatically for:
  • Complex tasks requiring planning ("build...", "create...", "implement...")
  • Architecture decisions ("should we use...", "which approach...")
  • Research requests ("research...", "analyze...", "compare...")
  • Refactoring work ("refactor...", "improve...", "optimize...")
  • Multi-step workflows (any task with 3+ steps)
  • Long coding sessions (automatic context monitoring)

本技能为任何复杂编码任务(不仅限于多文件项目)提供全面的上下文管理、规划策略和工作流优化方案。
必须使用本技能的场景:
  • ✅ 任何需要规划或策略的复杂任务
  • ✅ 多文件项目(HTML、CSS、JS、API、应用、文档)
  • ✅ 架构或设计决策
  • ✅ 需要分析的研究任务
  • ✅ 代码重构工作
  • ✅ 长时间编码会话(上下文优化)
  • ✅ 包含3个及以上步骤的多阶段工作流
本技能提供的功能:
  • 最优文件创建顺序 - 确定先创建哪些文件,管理依赖关系
  • 上下文高效工作流 - 平均节省62%的上下文资源
  • 扩展思维委托 - 深度分析的上下文效率提升23倍
  • 被动深度思考架构 - 无需消耗上下文资源即可获得分析深度
  • 渐进式任务分解 - 将复杂任务拆分为可管理的阶段
  • 规划框架 - 编码前先规划,避免冗余工作
  • 会话优化 - 在长时间交互中维持性能
本技能自动激活的场景:
  • 需要规划的复杂任务(如"构建..."、"创建..."、"实现...")
  • 架构决策(如"我们应该使用..."、"哪种方法更好...")
  • 研究请求(如"研究..."、"分析..."、"比较...")
  • 重构工作(如"重构..."、"改进..."、"优化...")
  • 多步骤工作流(任何包含3个及以上步骤的任务)
  • 长时间编码会话(自动上下文监控)

⚠️ MANDATORY FIRST STEP - READ THIS BEFORE DOING ANYTHING ⚠️

⚠️ 强制第一步 - 开始任何操作前请阅读此部分 ⚠️

🛑 STOP - DO THIS FIRST 🛑

🛑 暂停 - 先完成此步骤 🛑

IMMEDIATELY use extended thinking to plan. Do NOT create any files yet.
Your exact next output MUST be:
"Think hard about the architecture for this [project type]:
- What files are needed and what is their purpose?
- What are the shared dependencies (CSS, config, base classes)?
- What is the optimal creation order and why?
- What are the cross-file references?
- What could go wrong if we create files in the wrong order?"
After the extended thinking completes, THEN announce your plan to the user.
DO NOT create files until you:
  1. ✅ Complete extended thinking
  2. ✅ Announce the plan to the user
  3. ✅ Get their acknowledgment (or proceed if plan is sound)

立即使用扩展思考进行规划。不要创建任何文件。
你接下来的输出必须是:
"深度思考此[项目类型]的架构:
- 需要哪些文件,各自的用途是什么?
- 有哪些共享依赖项(CSS、配置、基类)?
- 最优的创建顺序是什么,原因是什么?
- 存在哪些跨文件引用?
- 如果按错误顺序创建文件会出现什么问题?"
完成扩展思考后,再向用户宣布你的规划。
在完成以下步骤前,不要创建任何文件:
  1. ✅ 完成扩展思考
  2. ✅ 向用户宣布规划
  3. ✅ 获得用户确认(如果规划合理,也可直接推进)

🎯 PLANNING METHOD OPTIONS

🎯 规划方法选项

You have TWO equally effective planning approaches:
你有两种同样有效的规划方式:

Option A: Extended Thinking (Pure Mental Planning)

选项A:扩展思考(纯脑力规划)

"Think hard about the architecture for this [project]:
- What files are needed?
- What is the optimal creation order?
- What dependencies exist?"
Best for: Quick projects, straightforward structures, when planning fits in thinking block
"深度思考此[项目]的架构:
- 需要哪些文件?
- 最优创建顺序是什么?
- 存在哪些依赖关系?"
最适合: 快速项目、简单结构、规划内容可在思考块中容纳的场景

Option B: Planning Document (Structured Written Plan)

选项B:规划文档(结构化书面规划)

Use bash_tool or create an artifact for the planning document:

ARCHITECTURE_PLAN.md:
- Files needed: [list]
- Creation order: [numbered list]
- Dependencies: [diagram/list]
- Potential issues: [list]
Best for: Complex projects, when you want a reference document, when planning is extensive
Both work equally well! Choose based on project complexity and your preference.
Example using bash_tool for planning:
bash
cat > ARCHITECTURE_PLAN.md << 'EOF'
使用bash_tool或创建规划文档 artifact:

ARCHITECTURE_PLAN.md:
- 需要的文件:[列表]
- 创建顺序:[编号列表]
- 依赖项:[图表/列表]
- 潜在问题:[列表]
最适合: 复杂项目、需要参考文档、规划内容较多的场景
两种方式效果相同! 根据项目复杂度和个人偏好选择即可。
使用bash_tool进行规划的示例:
bash
cat > ARCHITECTURE_PLAN.md << 'EOF'

Portfolio Website Architecture

作品集网站架构

Files Needed

需要的文件

  1. styles.css - Shared styling
  2. index.html - Home page
  3. about.html - About page
  4. projects.html - Projects page
  5. contact.html - Contact page
  1. styles.css - 共享样式
  2. index.html - 主页
  3. about.html - 关于页
  4. projects.html - 项目展示页
  5. contact.html - 联系页

Creation Order

创建顺序

  1. styles.css (shared dependency, created first)
  2. index.html (references styles.css)
  3. about.html (references styles.css)
  4. projects.html (references styles.css)
  5. contact.html (references styles.css)
  1. styles.css(共享依赖项,优先创建)
  2. index.html(引用styles.css)
  3. about.html(引用styles.css)
  4. projects.html(引用styles.css)
  5. contact.html(引用styles.css)

Cross-References

跨文件引用

  • All HTML files link to styles.css via <link rel="stylesheet">
  • All pages navigate to each other via <a href="..."> EOF

**Benefit of planning document:** You can reference it throughout the project, and it serves as documentation.

---## 💰 WHY THIS MATTERS: Token Savings

**Without planning:**
- Create files → Realize structure is wrong → Refactor → More explanations
- **Cost: ~8,000 tokens** (redundant work + explanations + fixes)

**With planning (this skill):**
- Think first → Create files in optimal order → Done correctly first time
- **Cost: ~3,000 tokens** (efficient creation only)

**💡 Savings: ~5,000 tokens (62% reduction) per multi-file project**

Over a long session with multiple projects, this compounds significantly.
  • 所有HTML文件通过<link rel="stylesheet">链接到styles.css
  • 所有页面通过<a href="...">实现相互导航 EOF

**规划文档的优势:** 你可以在整个项目过程中参考它,同时它也可作为项目文档。

---## 💰 为什么这很重要:令牌节省

**不进行规划的情况:**
- 创建文件 → 发现结构错误 → 重构 → 更多解释说明
- **成本:约8000个令牌**(冗余工作+解释+修复)

**使用规划(本技能)的情况:**
- 先思考 → 按最优顺序创建文件 → 一次完成正确构建
- **成本:约3000个令牌**(仅高效创建)

**💡 节省:每个多文件项目可节省约5000个令牌(减少62%)**

在包含多个项目的长会话中,这种节省会显著累积。

Real-World Token Savings by Project Size

不同规模项目的实际令牌节省

Small Project (3-4 files) - Portfolio Website
Without planning: ~6,000 tokens
  - Create HTML → Add inline styles → Extract CSS → Update refs
With planning: ~2,500 tokens
  - Plan → Create CSS → Create HTML with refs
💰 Savings: ~3,500 tokens (58%)
Medium Project (7-8 files) - Multi-page App
Without planning: ~12,000 tokens
  - Create pages → Realize shared components → Refactor → Fix imports
With planning: ~4,500 tokens
  - Plan → Create shared → Create pages → No refactoring
💰 Savings: ~7,500 tokens (63%)
Large Project (20+ files) - Full Application
Without planning: ~35,000 tokens
  - Create files randomly → Multiple refactoring cycles → Fix dependencies
With planning: ~12,000 tokens
  - Plan architecture → Create in optimal order → Minimal fixes
💰 Savings: ~23,000 tokens (66%)
Context window capacity:
  • Standard: 200K tokens
  • With planning: Can complete 16-17 medium projects
  • Without planning: Can complete only 7-8 medium projects
  • Effective capacity increase: 2.1x
---## 🚨 ACTIVATION TRIGGERS (You are seeing one of these RIGHT NOW)
If the user's request includes ANY of these phrases, this skill activated for a reason:
  • ✅ "create a website with..." ← YOU ARE HERE
  • ✅ "build 3+ pages/files"
  • ✅ "make a [type] application"
  • ✅ "create [home/about/contact] pages"
  • ✅ "build an API with..."
  • ✅ "generate documentation for..."
→ Your NEXT output should be extended thinking about architecture, NOT file creation

小型项目(3-4个文件)- 作品集网站
不规划:约6000个令牌
  - 创建HTML → 添加内联样式 → 提取到CSS → 更新引用
规划后:约2500个令牌
  - 规划 → 创建CSS → 创建带引用的HTML
💰 节省:约3500个令牌(58%)
中型项目(7-8个文件)- 多页面应用
不规划:约12000个令牌
  - 创建页面 → 发现需要共享组件 → 重构 → 修复导入
规划后:约4500个令牌
  - 规划 → 创建共享组件 → 创建页面 → 无需重构
💰 节省:约7500个令牌(63%)
大型项目(20个以上文件)- 完整应用
不规划:约35000个令牌
  - 随机创建文件 → 多次重构 → 修复依赖项
规划后:约12000个令牌
  - 规划架构 → 按最优顺序创建 → 极少需要修复
💰 节省:约23000个令牌(66%)
上下文窗口容量:
  • 标准:200000个令牌
  • 规划后:可完成16-17个中型项目
  • 不规划:仅能完成7-8个中型项目
  • 有效容量提升:2.1倍
---## 🚨 激活触发条件(你现在正遇到其中一种)
如果用户的请求包含以下任何短语,说明本技能已被激活:
  • ✅ "创建一个包含...的网站" ← 当前场景
  • ✅ "构建3个及以上页面/文件"
  • ✅ "制作一个[类型]应用"
  • ✅ "创建[主页/关于页/联系页]"
  • ✅ "构建一个包含...的API"
  • ✅ "为...生成文档"
→ 你的下一个输出应该是对架构的扩展思考,而非创建文件

📊 POST-PROJECT REFLECTION (Optional But Valuable)

📊 项目后反思(可选但有价值)

After completing a multi-file project, take a moment to assess the context savings:
完成多文件项目后,花点时间评估上下文节省情况:

Quick Self-Assessment Questions

快速自我评估问题

1. Did you plan before creating files? [Yes/No]
   
2. How many files did you create? [Number]

3. Did you have to refactor or fix file references? [Yes/No]
   
4. If you planned first:
   - Estimated context used: ~[2,500-4,500] tokens for [3-8] files
   
5. If you created without planning:
   - You likely used: ~[6,000-12,000] tokens
   - Potential savings missed: ~[3,500-7,500] tokens
1. 你在创建文件前是否进行了规划?[是/否]
   
2. 你创建了多少个文件?[数量]

3. 你是否需要重构或修复文件引用?[是/否]
   
4. 如果进行了规划:
   - 估计使用的上下文:约[2500-4500]个令牌(对应3-8个文件)
   
5. 如果未进行规划:
   - 你可能使用了:约[6000-12000]个令牌
   - 错失的节省量:约[3500-7500]个令牌

Success Indicators

成功指标

✅ You used the skill effectively if:
  • Created foundation files (CSS, config) before dependent files
  • No major refactoring needed after file creation
  • All file references worked on first try
  • Could describe file creation order before starting
  • Spent more time planning than fixing
⚠️ You could improve if:
  • Had to go back and add shared dependencies
  • Needed to refactor file structure after creation
  • Found broken references between files
  • Created files in no particular order
  • Spent more time fixing than planning
✅ 你有效使用了本技能的表现:
  • 先创建基础文件(CSS、配置),再创建依赖于它们的文件
  • 文件创建后无需进行重大重构
  • 所有文件引用首次尝试即正常工作
  • 在开始前能说明文件创建顺序
  • 花在规划上的时间多于修复的时间
⚠️ 你可以改进的地方:
  • 不得不回头添加共享依赖项
  • 文件创建后需要重构文件结构
  • 发现文件间存在损坏的引用
  • 无特定顺序地创建文件
  • 花在修复上的时间多于规划的时间

Context Savings Calculator

上下文节省计算器

Estimate your actual savings:
Files created: [N]
Did planning: [Yes/No]

If Yes:
  Tokens used: ~(N × 350) + 500 for planning
  Tokens saved: ~(N × 800)
  Efficiency: ~70%

If No:
  Tokens used: ~(N × 1,150) 
  Missed savings: ~(N × 800)
  Next time: Plan first!
Example for 5-file project:
  • With planning: ~2,250 tokens
  • Without planning: ~5,750 tokens
  • Actual savings: ~3,500 tokens (60%)
This reflection helps you recognize when the skill is working and when to apply it more strictly next time!

估算你的实际节省量:
创建的文件数量:[N]
是否进行了规划:[是/否]

如果是:
  使用的令牌数:~(N × 350) + 500(规划开销)
  节省的令牌数:~(N × 800)
  效率:~70%

如果否:
  使用的令牌数:~(N × 1150)
  错失的节省量:~(N × 800)
  下次改进:先规划!
5个文件项目的示例:
  • 规划后:约2250个令牌
  • 未规划:约5750个令牌
  • 实际节省:约3500个令牌(60%)
这种反思有助于你识别本技能何时发挥作用,以及下次何时需要更严格地应用它!

✓ REQUIRED WORKFLOW CHECKLIST

✓ 必选工作流检查清单

For EVERY multi-file project, follow this exact sequence:
☐ Step 1: THINK FIRST - Use "think hard" to plan architecture
         (List all files, determine optimal order, identify dependencies)
         
☐ Step 2: ANNOUNCE THE PLAN - Tell user the file creation order
         ("I'll create files in this order: 1. CSS, 2. index.html, 3...")
         
☐ Step 3: CREATE FOUNDATION FILES - Shared dependencies first
         (CSS files, config files, base classes)
         
☐ Step 4: CREATE DEPENDENT FILES - Files that use the foundations
         (HTML pages that reference CSS, components that use base classes)
         
☐ Step 5: VERIFY - Check all references/imports work
DO NOT skip Step 1. ALWAYS think before creating files.

对于每个多文件项目,请严格遵循以下顺序:
☐ 步骤1:先思考 - 使用"深度思考"规划架构
         (列出所有文件,确定最优顺序,识别依赖项)
         
☐ 步骤2:宣布规划 - 告知用户文件创建顺序
         ("我将按以下顺序创建文件:1. CSS, 2. index.html, 3...")
         
☐ 步骤3:创建基础文件 - 先创建共享依赖项
         (CSS文件、配置文件、基类)
         
☐ 步骤4:创建依赖文件 - 创建使用基础文件的文件
         (引用CSS的HTML页面、使用基类的组件)
         
☐ 步骤5:验证 - 检查所有引用/导入是否正常工作
不要跳过步骤1。始终在创建文件前进行思考。

🔴 COMMON MISTAKE TO AVOID

🔴 需避免的常见错误

WRONG APPROACH (what you might do without this skill):
User: "Create a portfolio with home, about, and projects pages"
You: [Creates index.html]
You: [Creates about.html]
You: [Creates projects.html]
You: [Realizes CSS should be shared, has to refactor]
Result: Wasted effort, redundant work
CORRECT APPROACH (what you MUST do with this skill):
User: "Create a portfolio with home, about, and projects pages"
You: "Think hard about the architecture first..."
     [Plans: Need 1 CSS file + 3 HTML files, CSS should come first]
You: "I'll create files in this order: 1. styles.css, 2. index.html, 3. about.html, 4. projects.html"
You: [Creates files in that order]
Result: Efficient, no redundant work

错误方法(不使用本技能时可能会做的事):
用户:"创建一个包含主页、关于页和项目页的作品集网站"
你:[创建index.html]
你:[创建about.html]
你:[创建projects.html]
你:[意识到应该共享CSS,不得不进行重构]
结果:浪费精力,冗余工作
正确方法(使用本技能时必须做的事):
用户:"创建一个包含主页、关于页和项目页的作品集网站"
你:"先深度思考架构..."
     [规划:需要1个CSS文件 + 3个HTML文件,应先创建CSS]
你:"我将按以下顺序创建文件:1. styles.css, 2. index.html, 3. about.html, 4. projects.html"
你:[按上述顺序创建文件]
结果:高效完成,无冗余工作

❌ MORE ANTI-PATTERNS (What NOT to Do)

❌ 更多反模式(请勿效仿)

Anti-Pattern 1: Creating JS Modules Before Main App File

反模式1:先创建JS模块再创建主应用文件

Wrong:
1. Create utils.js
2. Create helpers.js
3. Create api.js
4. Create app.js (main file that imports all the above)
Problem: Had to keep going back to app.js to add imports
Right:
1. Think about module structure
2. Create app.js (with import statements planned)
3. Create utils.js (knowing what app.js needs)
4. Create helpers.js (knowing what app.js needs)
5. Create api.js (knowing what app.js needs)
Benefit: App.js structured correctly from the start
错误:
1. 创建utils.js
2. 创建helpers.js
3. 创建api.js
4. 创建app.js(导入上述所有文件的主文件)
问题:不得不反复回到app.js添加导入
正确:
1. 思考模块结构
2. 创建app.js(规划好导入语句)
3. 创建utils.js(明确app.js的需求)
4. 创建helpers.js(明确app.js的需求)
5. 创建api.js(明确app.js的需求)
优势:app.js从一开始就结构正确

Anti-Pattern 2: Writing Inline Styles Then Extracting Later

反模式2:先写内联样式再提取到CSS

Wrong:
1. Create index.html with inline styles
2. Create about.html with inline styles
3. Realize styles are duplicated
4. Extract to styles.css
5. Update all HTML files to reference it
Problem: Redundant work, had to edit multiple files
Right:
1. Think: These pages will share styling
2. Create styles.css first
3. Create HTML files that reference styles.css
Benefit: No duplication, no refactoring needed
错误:
1. 创建带内联样式的index.html
2. 创建带内联样式的about.html
3. 发现样式重复
4. 提取到styles.css
5. 更新所有HTML文件以引用它
问题:冗余工作,需要编辑多个文件
正确:
1. 思考:这些页面将共享样式
2. 先创建styles.css
3. 创建引用styles.css的HTML文件
优势:无重复,无需重构

Anti-Pattern 3: Building Components Before Data Structure

反模式3:先构建组件再定义数据结构

Wrong:
1. Create UserProfile.jsx component
2. Create UserList.jsx component
3. Realize data structure is unclear
4. Go back and modify components to match data
Problem: Components built on assumptions
Right:
1. Think about data structure first
2. Create types.js or schema.js
3. Create components that use defined data structure
Benefit: Components built correctly from the start
错误:
1. 创建UserProfile.jsx组件
2. 创建UserList.jsx组件
3. 发现数据结构不明确
4. 回头修改组件以匹配数据
问题:组件基于假设构建
正确:
1. 先思考数据结构
2. 创建types.js或schema.js
3. 创建使用已定义数据结构的组件
优势:组件从一开始就构建正确

Anti-Pattern 4: Creating Pages Before Shared Layout

反模式4:先创建页面再创建共享布局

Wrong:
1. Create home.html with full layout
2. Create about.html with full layout
3. Realize layout should be shared
4. Extract to layout component/template
5. Refactor all pages
Problem: Major refactoring required
Right:
1. Think: Pages will share layout
2. Create layout.html or Layout component
3. Create pages that use the layout
Benefit: DRY from the start
错误:
1. 创建带完整布局的home.html
2. 创建带完整布局的about.html
3. 发现布局应该共享
4. 提取到布局组件/模板
5. 重构所有页面
问题:需要重大重构
正确:
1. 思考:页面将共享布局
2. 创建layout.html或Layout组件
3. 创建使用该布局的页面
优势:从一开始就遵循DRY原则

Anti-Pattern 5: Creating Config Files Last

反模式5:最后创建配置文件

Wrong:
1. Create multiple files with hardcoded values
2. Realize config should be centralized
3. Create config.js
4. Update all files to use config
Problem: Config scattered, hard to change
Right:
1. Think: What values will be used across files?
2. Create config.js first
3. Create other files that import config
Benefit: Centralized configuration from start

错误:
1. 创建多个包含硬编码值的文件
2. 发现配置应该集中管理
3. 创建config.js
4. 更新所有文件以使用config
问题:配置分散,难以修改
正确:
1. 思考:哪些值会在多个文件中使用?
2. 先创建config.js
3. 创建导入config的其他文件
优势:从一开始就集中配置

📖 PART 1: UNIVERSAL GUIDANCE (All Users - Web, API, CLI)

📖 第一部分:通用指南(所有用户 - Web、API、CLI)

The sections below apply to ALL users. Read these first regardless of your environment.

以下部分适用于所有用户。无论你的环境如何,请先阅读这些内容。

Core Principles (All Environments)

核心原则(所有环境)

1. Extended Thinking for Complex Tasks

1. 复杂任务使用扩展思考

Use extended thinking to keep reasoning separate from main context:
Trigger phrases:
  • "think about..."
    - Standard extended thinking
  • "think hard about..."
    - More thorough analysis
  • "think harder about..."
    - Deep analysis
  • "ultrathink..."
    - Maximum thinking budget
When to use:
  • Planning complex implementations
  • Analyzing multiple approaches
  • Design decisions with tradeoffs
  • Any task requiring deep reasoning
Benefit: Reasoning happens in separate blocks that don't clutter your main context.
使用扩展思考将推理与主上下文分离:
触发短语:
  • "思考..."
    - 标准扩展思考
  • "深度思考..."
    - 更彻底的分析
  • "更深入地思考..."
    - 深度分析
  • "极致思考..."
    - 最大思考预算
使用场景:
  • 规划复杂实现
  • 分析多种方法
  • 权衡设计决策
  • 任何需要深度推理的任务
优势: 推理在独立块中进行,不会使主上下文混乱。

2. Artifacts for Content Offloading

2. 使用Artifact卸载内容

Create artifacts for substantial content instead of inline responses:
Use artifacts for:
  • Code files (>20 lines)
  • Documents, reports, articles
  • Data analysis results
  • Complex visualizations
  • Any reusable content
Why it works: Content lives in artifacts, not the conversation context.
为大量内容创建artifact,而非在对话中内联响应:
使用artifact的场景:
  • 代码文件(超过20行)
  • 文档、报告、文章
  • 数据分析结果
  • 复杂可视化
  • 任何可重用内容
为什么有效: 内容存储在artifact中,而非对话上下文。

3. Progressive Task Decomposition

3. 渐进式任务分解

Break complex requests into phases:
Instead of: "Build me a complete app with authentication, database, and frontend"
Do this:
Phase 1: "think about the architecture for this app"
[Review architecture plan]

Phase 2: "Create the database schema"
[Review schema]

Phase 3: "Build the authentication system"
[Continue phase by phase]
Benefit: Each phase has fresh context, no accumulation of old decisions.
将复杂请求拆分为多个阶段:
不要这样做: "为我构建一个包含认证、数据库和前端的完整应用"
应该这样做:
阶段1:"思考此应用的架构"
[审核架构规划]

阶段2:"创建数据库模式"
[审核模式]

阶段3:"构建认证系统"
[继续分阶段推进]
优势: 每个阶段都有全新的上下文,不会累积旧决策。

4. Explicit Context Boundaries

4. 明确上下文边界

Signal when to start fresh:
  • "Let's start fresh with a new approach"
  • "Setting aside the previous discussion..."
  • "Here's a new angle on this problem..."
In Claude Code: Use
/clear
command In web/API: Explicitly state context reset
明确表示何时开始新的上下文:
  • "让我们用新方法重新开始"
  • "抛开之前的讨论..."
  • "这是对此问题的新角度..."
在Claude Code中: 使用
/clear
命令 在Web/API中: 明确声明上下文重置

Multi-File Project Planning (Critical Section)

多文件项目规划(关键部分)

📌 QUICK REMINDER: Did you think first? If not, go back to "STOP - DO THIS FIRST" above.
When creating any project with 3+ related files, ALWAYS start with this planning workflow:
📌 快速提醒:你是否先进行了思考?如果没有,请回到上方的"暂停 - 先完成此步骤"部分。
当创建任何包含3个及以上相关文件的项目时,始终从以下规划工作流开始:

Step 1: Architecture Planning

步骤1:架构规划

Choose your planning method (both equally effective):
Method A: Extended Thinking
"Think hard about the architecture for this [project]:
- What files are needed and their purpose?
- What are shared dependencies?
- What is optimal creation order?
- What are cross-file references?
- What could go wrong?"
Method B: Planning Document
Create ARCHITECTURE_PLAN.md (via bash_tool or artifact):
- Files needed with purposes
- Shared dependencies
- Numbered creation order with reasoning
- Cross-file reference map
- Potential issues to avoid
Before creating any files, use extended thinking OR create planning document with this template:
ARCHITECTURE PLAN TEMPLATE:

□ FILES NEEDED:
  - [filename]: [purpose]
  - [filename]: [purpose]
  - [filename]: [purpose]

□ SHARED DEPENDENCIES (must be created first):
  - [dependency]: [what files need this]

□ CREATION ORDER (numbered with reasoning):
  1. [file] - Reason: [why this first]
  2. [file] - Reason: [why this second]
  3. [file] - Reason: [why this third]

□ CROSS-FILE REFERENCES:
  - [file A] references [file B] via [method]
  - [file C] imports [file D] via [method]

□ POTENTIAL ISSUES TO AVOID:
  - [what could go wrong]
  - [common mistake]
Example filled template for portfolio website:
ARCHITECTURE PLAN:

□ FILES NEEDED:
  - styles.css: Shared styling for all pages
  - index.html: Home page with navigation
  - about.html: About page
  - projects.html: Portfolio showcase
  - contact.html: Contact form

□ SHARED DEPENDENCIES:
  - styles.css: All HTML files need this for consistent styling

□ CREATION ORDER:
  1. styles.css - Reason: Shared dependency, all HTML files will reference it
  2. index.html - Reason: Main entry point, establishes structure
  3. about.html - Reason: References styles.css which now exists
  4. projects.html - Reason: References styles.css which now exists
  5. contact.html - Reason: References styles.css which now exists

□ CROSS-FILE REFERENCES:
  - All HTML files link to styles.css via <link rel="stylesheet">
  - All HTML pages link to each other via <a href="...">

□ POTENTIAL ISSUES TO AVOID:
  - Creating HTML before CSS → Would require going back to add links
  - Inline styles in HTML → Would require extraction later
  - Inconsistent navigation → Hard to maintain across files
Use this template in your extended thinking output.
选择你的规划方法(两种方法同样有效):
方法A:扩展思考
"深度思考此[项目]的架构:
- 需要哪些文件,各自的用途是什么?
- 存在哪些共享依赖项?
- 最优创建顺序是什么?
- 存在哪些跨文件引用?
- 可能会出现什么问题?"
方法B:规划文档
创建ARCHITECTURE_PLAN.md(通过bash_tool或artifact):
- 需要的文件及其用途
- 共享依赖项
- 带理由的编号创建顺序
- 跨文件引用映射
- 需避免的潜在问题
在创建任何文件前,使用扩展思考或使用以下模板创建规划文档:
架构规划模板:

□ 需要的文件:
  - [文件名]:[用途]
  - [文件名]:[用途]
  - [文件名]:[用途]

□ 共享依赖项(必须先创建):
  - [依赖项]:[哪些文件需要它]

□ 创建顺序(带理由的编号列表):
  1. [文件] - 理由:[为什么先创建]
  2. [文件] - 理由:[为什么第二个创建]
  3. [文件] - 理由:[为什么第三个创建]

□ 跨文件引用:
  - [文件A] 通过[方法]引用[文件B]
  - [文件C] 通过[方法]导入[文件D]

□ 需避免的潜在问题:
  - [可能出现的问题]
  - [常见错误]
作品集网站的填充模板示例:
架构规划:

□ 需要的文件:
  - styles.css:所有页面的共享样式
  - index.html:带导航的主页
  - about.html:关于页
  - projects.html:作品集展示页
  - contact.html:联系表单页

□ 共享依赖项:
  - styles.css:所有HTML文件都需要它以保持样式一致

□ 创建顺序:
  1. styles.css - 理由:共享依赖项,所有HTML文件都将引用它
  2. index.html - 理由:主入口点,确立结构
  3. about.html - 理由:引用已存在的styles.css
  4. projects.html - 理由:引用已存在的styles.css
  5. contact.html - 理由:引用已存在的styles.css

□ 跨文件引用:
  - 所有HTML文件通过<link rel="stylesheet">链接到styles.css
  - 所有HTML页面通过<a href="...">相互导航

□ 需避免的潜在问题:
  - 在创建CSS之前创建HTML → 需要回头添加链接
  - 在HTML中使用内联样式 → 之后需要提取
  - 导航不一致 → 难以在多个文件中维护
在你的扩展思考输出中使用此模板。

Step 2: Optimal File Creation Order

步骤2:最优文件创建顺序

General principles:
  1. Foundations first - Shared dependencies before dependents
    • CSS files before HTML files that use them
    • Configuration files before code that needs them
    • Base classes before derived classes
  2. Core before features - Essential files before optional ones
    • index.html before other pages
    • main.js before feature modules
    • Core API before additional endpoints
  3. Structure before content - Layout before details
    • HTML structure before detailed content
    • API structure before implementation details
    • Component scaffolds before full logic
Common file creation orders:
Website project:
1. styles.css (shared styling)
2. index.html (home page - references styles.css)
3. about.html (references styles.css)
4. projects.html (references styles.css)
5. contact.html (references styles.css)
6. script.js (if needed)
React application:
1. package.json (dependencies)
2. App.js (main component)
3. components/Header.js (layout components)
4. components/Footer.js
5. pages/Home.js (page components)
6. pages/About.js
7. styles/main.css
Backend API:
1. config.js (configuration)
2. database.js (DB connection)
3. models/User.js (data models)
4. routes/auth.js (route handlers)
5. routes/api.js
6. server.js (entry point)
一般原则:
  1. 先基础后依赖 - 先创建共享依赖项,再创建依赖它们的文件
    • 在使用CSS的HTML文件之前创建CSS文件
    • 在需要配置的代码之前创建配置文件
    • 在派生类之前创建基类
  2. 先核心后功能 - 先创建必要文件,再创建可选文件
    • 在其他页面之前创建index.html
    • 在功能模块之前创建main.js
    • 在附加端点之前创建核心API
  3. 先结构后内容 - 先创建布局,再填充细节
    • 在详细内容之前创建HTML结构
    • 在实现细节之前创建API结构
    • 在完整逻辑之前创建组件框架
常见文件创建顺序:
网站项目:
1. styles.css(共享样式)
2. index.html(主页 - 引用styles.css)
3. about.html(引用styles.css)
4. projects.html(引用styles.css)
5. contact.html(引用styles.css)
6. script.js(如果需要)
React应用:
1. package.json(依赖项)
2. App.js(主组件)
3. components/Header.js(布局组件)
4. components/Footer.js
5. pages/Home.js(页面组件)
6. pages/About.js
7. styles/main.css
后端API:
1. config.js(配置)
2. database.js(数据库连接)
3. models/User.js(数据模型)
4. routes/auth.js(路由处理程序)
5. routes/api.js
6. server.js(入口点)

Step 3: Create Files with Awareness

步骤3:有意识地创建文件

As you create each file:
  • Reference what's already been created
  • Note what future files will depend on this one
  • Keep consistent naming and structure
  • Add comments about dependencies
创建每个文件时:
  • 参考已创建的内容
  • 记录未来哪些文件将依赖此文件
  • 保持一致的命名和结构
  • 添加关于依赖项的注释

Step 4: Verify and Test

步骤4:验证和测试

After creating all files, perform these verification checks:
创建所有文件后,执行以下验证检查:

✓ File Path Verification

✓ 文件路径验证

□ Check all file paths are correct
  - CSS links: <link href="styles.css"> (not "style.css" or "css/styles.css")
  - JS scripts: <script src="script.js"> 
  - Images: <img src="image.png">
  - Relative paths match actual file structure
□ 检查所有文件路径是否正确
  - CSS链接:<link href="styles.css">(不是"style.css"或"css/styles.css")
  - JS脚本:<script src="script.js"> 
  - 图片:<img src="image.png">
  - 相对路径与实际文件结构匹配

✓ Reference Loading Verification

✓ 引用加载验证

□ Ensure CSS/JS references load properly
  - HTML files can find the CSS file
  - JavaScript imports resolve correctly
  - No 404 errors for missing files
  - Correct syntax in link/script tags
□ 确保CSS/JS引用正确加载
  - HTML文件可以找到CSS文件
  - JavaScript导入解析正确
  - 没有缺失文件导致的404错误
  - 链接/脚本标签语法正确

✓ Navigation Verification (for websites)

✓ 导航验证(针对网站)

□ Test navigation between pages
  - All navigation links point to correct files
  - Links use correct relative paths
  - No broken navigation (links to non-existent pages)
  - Back/forward navigation works logically
□ 测试页面间的导航
  - 所有导航链接指向正确的文件
  - 链接使用正确的相对路径
  - 没有损坏的导航(指向不存在页面的链接)
  - 前进/后退导航逻辑正常

✓ Cross-File Reference Verification

✓ 跨文件引用验证

□ Validate cross-file dependencies work
  - Components import correctly
  - Modules can access exported functions
  - Shared utilities are accessible
  - API calls reference correct endpoints
□ 验证跨文件依赖项是否正常工作
  - 组件导入正确
  - 模块可以访问导出的函数
  - 共享工具可访问
  - API调用引用正确的端点

✓ Consistency Verification

✓ 一致性验证

□ Check consistency across files
  - Naming conventions are consistent
  - Styling is uniform (if using shared CSS)
  - Code structure follows same patterns
  - Documentation style matches across files
Example verification for portfolio website:
After creating styles.css, index.html, about.html, projects.html, contact.html:

✓ Verification checklist:
  [✓] All HTML files have <link rel="stylesheet" href="styles.css">
  [✓] styles.css exists and has content
  [✓] Navigation links: 
      - index.html links to about.html, projects.html, contact.html ✓
      - All other pages link back to index.html ✓
  [✓] All pages use consistent styling from styles.css ✓
  [✓] No broken links or missing file references ✓

Result: Project structure verified, ready to use!
If verification fails, fix issues before considering the project complete.
□ 检查文件间的一致性
  - 命名约定一致
  - 样式统一(如果使用共享CSS)
  - 代码结构遵循相同模式
  - 文档风格在所有文件中一致
作品集网站的验证示例:
创建styles.css、index.html、about.html、projects.html、contact.html后:

✓ 验证检查清单:
  [✓] 所有HTML文件都包含<link rel="stylesheet" href="styles.css">
  [✓] styles.css存在且有内容
  [✓] 导航链接:
      - index.html链接到about.html、projects.html、contact.html ✓
      - 所有其他页面链接回index.html ✓
  [✓] 所有页面使用styles.css提供的一致样式 ✓
  [✓] 没有损坏的链接或缺失的文件引用 ✓

结果:项目结构已验证,可投入使用!
如果验证失败,请在认为项目完成前修复问题。

When to Use This Planning Approach

何时使用此规划方法

ALWAYS plan first for:
  • Websites with multiple pages (3+ HTML files)
  • Applications with multiple components
  • Projects with shared dependencies (CSS, config files)
  • API implementations with multiple endpoints
  • Documentation sets with multiple files
  • Any project where files reference each other
Don't need planning for:
  • Single file creations
  • Truly independent files with no relationships
  • Simple, obvious structures
始终先规划的场景:
  • 包含多个页面的网站(3个及以上HTML文件)
  • 包含多个组件的应用
  • 有共享依赖项的项目(CSS、配置文件)
  • 包含多个端点的API实现
  • 包含多个文件的文档集
  • 任何文件间存在引用的项目
无需规划的场景:
  • 单个文件创建
  • 真正独立、无关联的文件
  • 简单、明显的结构

Passive Deep Thinking Architecture

被动深度思考架构

The key insight: Extended thinking can happen in isolated contexts (subagents/artifacts), keeping the main session lean while still getting deep analysis.
核心洞察: 扩展思考可以在独立上下文(子代理/artifact)中进行,使主会话保持精简,同时仍能获得深度分析。

The Architectural Pattern

架构模式

Main Session (Orchestrator)
├─ Stays high-level and focused
├─ Makes decisions based on summaries
└─ Delegates complex analysis

        ↓ delegates with thinking triggers ↓

Analysis Layer (Agents/Artifacts)
├─ Extended thinking happens HERE (5K+ tokens)
├─ Deep reasoning happens HERE
├─ Context-heavy work happens HERE
└─ Returns concise summaries UP (~200 tokens)

        ↑ returns actionable conclusions ↑

Main Session
└─ Receives well-reasoned recommendations
└─ Context stays clean for sustained work
主会话(协调器)
├─ 保持高层级和聚焦
├─ 根据摘要做出决策
└─ 委托复杂分析

        ↓ 使用思考触发器委托 ↓

分析层(代理/Artifact)
├─ 扩展思考在此进行(5000+令牌)
├─ 深度推理在此进行
├─ 上下文密集型工作在此进行
└─ 返回简洁摘要给上层(~200令牌)

        ↑ 返回可操作结论 ↑

主会话
└─ 收到经过充分推理的建议
└─ 上下文保持清洁,以持续工作

How This Achieves Passive Deep Thinking

如何实现被动深度思考

Without thinking delegation:
  • Extended thinking happens in main context
  • Reasoning accumulates (~5K tokens per analysis)
  • Context fills quickly over long sessions
  • Eventually hits limits
With thinking delegation:
  • Subagents/artifacts do extended thinking in isolation
  • Main context only receives summaries (~200 tokens)
  • Can sustain 25+ analyses before context issues
  • Deep thinking happens passively through architecture
Key benefit: You get the depth of extended thinking without the context cost.
不使用思考委托的情况:
  • 扩展思考在主上下文中进行
  • 推理累积(每次分析约5000个令牌)
  • 长会话中上下文迅速填满
  • 最终达到限制
使用思考委托的情况:
  • 子代理/artifact在隔离环境中进行扩展思考
  • 主上下文仅接收摘要(~200令牌)
  • 可在出现上下文问题前持续进行25+次分析
  • 通过架构被动实现深度思考
核心优势: 你无需付出上下文成本即可获得扩展思考的深度。

Implementation by Environment

按环境实现

Claude Code: Thinking Subagents

Claude Code:思考子代理

Create subagents that automatically use extended thinking:
bash
undefined
创建自动使用扩展思考的子代理:
bash
undefined

Create a deep analyzer for complex decisions

为复杂决策创建深度分析器

python scripts/create_subagent.py architecture-advisor --type deep_analyzer
python scripts/create_subagent.py architecture-advisor --type deep_analyzer

Create thinking-enabled researcher

创建支持思考的研究员

python scripts/create_subagent.py pattern-researcher --type researcher

**Usage:**
Main session: "I need to decide between microservices and monolith" ↓ /agent architecture-advisor "Analyze microservices vs monolith for an e-commerce platform with 10M users, considering team size of 8 developers" ↓ Subagent's isolated context:
  • Uses "ultrathink" automatically
  • 5K+ tokens of deep reasoning
  • Evaluates tradeoffs thoroughly ↓ Returns to main: "After deep analysis, I recommend starting with a modular monolith because [3 key reasons]. Microservices would add complexity your team size can't support yet." ↓ Main session: Receives actionable advice, context clean

**Context saved:** ~4,800 tokens per analysis
python scripts/create_subagent.py pattern-researcher --type researcher

**用法:**
主会话:"我需要在微服务和单体架构之间做出选择" ↓ /agent architecture-advisor "分析微服务与单体架构 针对拥有1000万用户的电商平台,考虑8人开发团队的情况" ↓ 子代理的隔离上下文:
  • 自动使用"极致思考"
  • 5000+令牌的深度推理
  • 全面权衡利弊 ↓ 返回主会话:"经过深度分析,我建议从模块化单体架构开始,因为[3个关键原因]。你的团队规模目前无法支撑微服务带来的复杂性。" ↓ 主会话:收到可操作建议,上下文保持清洁

**节省的上下文:** 每次分析约4800个令牌

Web/API: Thinking Artifacts

Web/API:思考Artifact

Use artifacts as "thinking containers":
Pattern:
User: "Analyze the best database for this use case"

Claude: "I'll create a deep analysis artifact where I can think 
through this thoroughly."

[Creates artifact: "database-analysis.md"]
[Inside artifact:
  - Extended thinking block (collapsed in UI)
  - Detailed analysis
  - Comparison tables
  - Final recommendation
]

Main conversation: "Based on the analysis artifact, I recommend 
PostgreSQL because [2-sentence summary]. See artifact for complete 
reasoning including performance comparisons and scaling considerations."
Why this works:
  • Thinking is visually separated (in artifact)
  • Main conversation stays summary-focused
  • User can reference artifact when needed
  • Conversational context stays lean
使用artifact作为"思考容器":
模式:
用户:"分析此用例的最佳数据库"

Claude:"我将创建一个深度分析artifact,以便彻底思考这个问题。"

[创建artifact:"database-analysis.md"]
[在artifact内部:
  - 扩展思考块(在UI中折叠)
  - 详细分析
  - 对比表格
  - 最终建议
]

主对话:"根据分析artifact,我推荐PostgreSQL,因为[2句话总结]。查看artifact获取完整推理,包括性能对比和扩展考虑。"
为什么有效:
  • 思考在视觉上与对话分离(在artifact中)
  • 主对话保持聚焦于摘要
  • 用户需要时可参考artifact
  • 对话上下文保持精简

When to Use Thinking Delegation

何时使用思考委托

Delegate to thinking agents/artifacts for:
  • Architecture decisions
  • Technology evaluations
  • Complex tradeoff analysis
  • Multi-factor comparisons
  • Design pattern selection
  • Performance optimization strategies
  • Security assessment
  • Refactoring approach planning
Keep in main context for:
  • Simple implementation
  • Quick queries
  • Tactical decisions with obvious answers
  • Tasks requiring full project context
将任务委托给思考代理/artifact的场景:
  • 架构决策
  • 技术评估
  • 复杂权衡分析
  • 多因素比较
  • 设计模式选择
  • 性能优化策略
  • 安全评估
  • 重构方法规划
在主上下文中处理的场景:
  • 简单实现
  • 快速查询
  • 答案明显的战术决策
  • 需要完整项目上下文的任务

Example: Complex Decision with Thinking Delegation

示例:使用思考委托进行复杂决策

Scenario: Choose state management for React app
Traditional approach (main context):
User: "What state management should I use?"
Claude: [5K tokens of thinking in main context]
Claude: [Another 2K tokens explaining recommendation]
Total: ~7K tokens consumed
Thinking delegation approach:
User: "What state management should I use for a large e-commerce app?"

Claude Code:
"This warrants deep analysis. Let me delegate to a deep analyzer."
/agent architecture-advisor "Think deeply about state management 
options (Redux, Zustand, Jotai, Context) for large-scale e-commerce 
with real-time inventory"

[Subagent uses ultrathink in isolated context - 5K tokens]
[Returns summary - 200 tokens]

Main context: "The advisor recommends Zustand for these reasons..."
Total in main: ~300 tokens
Context efficiency: 23x improvement while maintaining analytical depth
场景:为React应用选择状态管理
传统方法(主上下文):
用户:"我应该使用什么状态管理?"
Claude:[在主上下文中进行5000令牌的思考]
Claude:[再用2000令牌解释建议]
总计:约7000个令牌消耗
思考委托方法:
用户:"我应该为大型电商应用使用什么状态管理?"

Claude Code:
"这需要深度分析。让我委托给深度分析器。"
/agent architecture-advisor "深入思考状态管理
选项(Redux、Zustand、Jotai、Context),针对大型电商应用
带实时库存功能"

[子代理在隔离上下文中使用极致思考 - 5000令牌]
[返回摘要 - 200令牌]

主上下文:"顾问推荐Zustand,原因如下..."
主上下文中的总消耗:约300令牌
上下文效率:在保持分析深度的同时,提升23倍

Compound Effect Over Long Sessions

长会话中的复合效应

Session without thinking delegation:
  • Analysis 1: 7K tokens
  • Analysis 2: 7K tokens
  • Analysis 3: 7K tokens
  • Analysis 4: 7K tokens
  • Analysis 5: 7K tokens
  • Total: 35K tokens (17% of 200K context)
Session with thinking delegation:
  • Analysis 1: 300 tokens
  • Analysis 2: 300 tokens
  • Analysis 3: 300 tokens
  • Analysis 4: 300 tokens
  • Analysis 5: 300 tokens
  • Total: 1.5K tokens (0.75% of 200K context)
Result: Can sustain 23x more analyses in same context window while maintaining analytical rigor.
不使用思考委托的会话:
  • 分析1:7000令牌
  • 分析2:7000令牌
  • 分析3:7000令牌
  • 分析4:7000令牌
  • 分析5:7000令牌
  • 总计:35000令牌(占200000上下文的17%)
使用思考委托的会话:
  • 分析1:300令牌
  • 分析2:300令牌
  • 分析3:300令牌
  • 分析4:300令牌
  • 分析5:300令牌
  • 总计:1500令牌(占200000上下文的0.75%)
结果:在相同的上下文窗口中,可维持23倍以上的分析次数,同时保持分析严谨性。

Universal Strategies

通用策略

Strategy 1: Research → Think → Implement

策略1:研究 → 思考 → 实现

Works in all environments:
Step 1: Research phase
"Search for [topic] and gather key information"

Step 2: Analysis phase  
"think hard about the best approach based on those findings"

Step 3: Implementation phase
"Now implement [specific task] using the approach we decided"
Why it works: Each phase has clear purpose, prevents context sprawl.
适用于所有环境:
步骤1:研究阶段
"搜索[主题]并收集关键信息"

步骤2:分析阶段  
"根据这些发现,深度思考最佳方法"

步骤3:实现阶段
"现在使用我们确定的方法实现[具体任务]"
为什么有效: 每个阶段都有明确的目标,防止上下文扩散。

Strategy 2: Artifact-Driven Development

策略2:Artifact驱动开发

For coding tasks:
1. "Create a [file type] artifact with [functionality]"
2. Test/review the artifact
3. "Update the artifact to add [feature]"
4. Iterate within the artifact
Why it works: Code lives in artifact, conversation stays focused on decisions.
针对编码任务:
1. "创建一个[文件类型]artifact,包含[功能]"
2. 测试/审核artifact
3. "更新artifact以添加[功能]"
4. 在artifact内迭代
为什么有效: 代码存储在artifact中,对话聚焦于决策。

Strategy 3: Document Plans Before Executing

策略3:执行前记录规划

For complex projects:
1. "think about the plan for this project"
2. "Create a markdown artifact with the plan"
3. Reference the plan artifact as you work
4. Update the plan artifact as decisions change
Why it works: Plan persists in artifact, you can reference it without re-explaining.
针对复杂项目:
1. "思考此项目的规划"
2. "创建一个markdown artifact记录规划"
3. 工作时参考规划artifact
4. 决策变更时更新规划artifact
为什么有效: 规划存储在artifact中,你无需重新解释即可参考。

Strategy 4: Chunked Research

策略4:分块研究

For large research tasks:
1. "Research aspect A of [topic]"
2. "Create a summary artifact"
3. [New conversation or context reset]
4. "Research aspect B of [topic]" 
5. "Create a summary artifact"
6. "Synthesize findings from both research phases"
Why it works: Each research phase stays focused, final synthesis combines cleanly.
针对大型研究任务:
1. "研究[主题]的A方面"
2. "创建摘要artifact"
3. [新对话或上下文重置]
4. "研究[主题]的B方面" 
5. "创建摘要artifact"
6. "综合两个研究阶段的发现"
为什么有效: 每个研究阶段保持聚焦,最终综合起来清晰明了。

Environment-Specific Techniques

特定环境技术

Web Interface & API

Web界面与API

Strategies:
  • Use extended thinking liberally for complex reasoning
  • Create artifacts for code, documents, and substantial content
  • Break long tasks into explicit phases
  • Signal context resets when changing direction
Example workflow:
"I need to build a REST API. Let me break this into phases:

Phase 1: ultrathink about the API design and architecture
[Review thinking output]

Phase 2: Create an artifact with the OpenAPI specification
[Review spec]

Phase 3: Implement the authentication endpoints
[Continue implementation]
策略:
  • 复杂推理时大量使用扩展思考
  • 为代码、文档和大量内容创建artifact
  • 将长任务拆分为明确的阶段
  • 改变方向时明确表示上下文重置
示例工作流:
"我需要构建一个REST API。让我将其拆分为多个阶段:

阶段1:极致思考API设计和架构
[审核思考输出]

阶段2:创建包含OpenAPI规范的artifact
[审核规范]

阶段3:实现认证端点
[继续实现]

Claude Code (CLI)

Claude Code(CLI)

Additional commands:
  • /clear
    - Reset context between tasks
  • /compact
    - Compress context while keeping key decisions
  • /continue
    - Resume previous session
  • Subagents - Delegate research/testing to isolated contexts
Generate project-specific CLAUDE.md:
bash
python scripts/generate_claude_md.py --type [TYPE] --output ./CLAUDE.md
Create subagents for recurring tasks:
bash
python scripts/create_subagent.py [NAME] --type [TYPE]
See Claude Code Tooling section below for details.
附加命令:
  • /clear
    - 任务间重置上下文
  • /compact
    - 压缩上下文,同时保留关键决策
  • /continue
    - 恢复之前的会话
  • 子代理 - 将研究/测试委托给隔离上下文
生成项目特定的CLAUDE.md:
bash
python scripts/generate_claude_md.py --type [TYPE] --output ./CLAUDE.md
为重复任务创建子代理:
bash
python scripts/create_subagent.py [NAME] --type [TYPE]
有关详细信息,请参阅下文的Claude Code工具部分。

Common Workflows (All Environments)

常见工作流(所有环境)

Workflow 0: Multi-File Website/Project Creation ⭐ MOST COMMON

工作流0:多文件网站/项目创建 ⭐ 最常见

🚨 If user said: "create a website/app with multiple pages" → YOU ARE IN THIS WORKFLOW RIGHT NOW
MANDATORY WORKFLOW - FOLLOW THIS EXACT SEQUENCE:
✓ STEP 1: STOP AND THINK (DO THIS FIRST, ALWAYS)
   Output: "Think hard about the architecture for this [project]..."
   [Extended thinking plans: files needed, creation order, dependencies]

✓ STEP 2: ANNOUNCE THE PLAN
   Output: "I'll create these files in this order:
            1. styles.css (shared styling)
            2. index.html (home page)
            3. about.html
            4. projects.html
            5. contact.html"

✓ STEP 3: CREATE FOUNDATION FILES FIRST
   Create: styles.css
   
✓ STEP 4: CREATE DEPENDENT FILES
   Create: index.html (references styles.css)
   Create: about.html (references styles.css)
   Create: projects.html (references styles.css)
   Create: contact.html (references styles.css)

✓ STEP 5: VERIFY
   Check: All HTML files reference styles.css correctly
Example: Portfolio Website Request
User: "Create a portfolio website with home, about, projects, and contact pages"

🛑 BEFORE YOU CREATE ANY FILES, YOU MUST OUTPUT:

"Let me think hard about the architecture first..."

[Extended thinking output should plan:
 - Files needed: index.html, about.html, projects.html, contact.html, styles.css
 - Optimal order: styles.css FIRST (it's a shared dependency), then HTML pages
 - Dependencies: All HTML files will reference styles.css
 - Structure: Simple multi-page site with shared stylesheet]

THEN announce the plan:

"I'll create the files in this order:

1. styles.css - Shared styling for all pages
2. index.html - Home page (will reference styles.css)
3. about.html - About page (will reference styles.css)
4. projects.html - Projects page (will reference styles.css)
5. contact.html - Contact page (will reference styles.css)

This order ensures all dependencies are in place before files that need them."

THEN create files in that exact order.
❌ WRONG - What NOT to do:
User: "Create a portfolio website with home, about, projects, and contact pages"

[Immediately creates index.html without thinking]
[Creates about.html]
[Creates projects.html]
[Realizes CSS should be shared, has to go back and add it]

This wastes effort and context!
✅ RIGHT - What to do:
User: "Create a portfolio website with home, about, projects, and contact pages"

"Think hard about architecture..." [Plans first]
"I'll create in this order: CSS first, then HTML pages" [Announces plan]
[Creates styles.css]
[Creates HTML pages that reference styles.css]

Efficient! No redundant work!

🚨 如果用户说:"创建一个包含多个页面的网站/应用" → 你当前正处于此工作流
强制工作流 - 严格遵循此顺序:
✓ 步骤1:暂停并思考(始终先完成此步骤)
   输出:"深度思考此[项目]的架构..."
   [扩展思考规划:需要的文件、创建顺序、依赖项]

✓ 步骤2:宣布规划
   输出:"我将按以下顺序创建这些文件:
            1. styles.css(共享样式)
            2. index.html(主页)
            3. about.html
            4. projects.html
            5. contact.html"

✓ 步骤3:先创建基础文件
   创建:styles.css
   
✓ 步骤4:创建依赖文件
   创建:index.html(引用styles.css)
   创建:about.html(引用styles.css)
   创建:projects.html(引用styles.css)
   创建:contact.html(引用styles.css)

✓ 步骤5:验证
   检查:所有HTML文件是否正确引用styles.css
示例:作品集网站请求
用户:"创建一个包含主页、关于页、项目页和联系页的作品集网站"

🛑 在创建任何文件之前,你必须输出:

"让我先深度思考架构..."

[扩展思考输出应规划:
 - 需要的文件:index.html、about.html、projects.html、contact.html、styles.css
 - 最优顺序:先创建styles.css(它是共享依赖项),然后创建HTML页面
 - 依赖项:所有HTML文件都将引用styles.css
 - 结构:带共享样式表的简单多页面网站]

然后宣布规划:

"我将按以下顺序创建文件:

1. styles.css - 所有页面的共享样式
2. index.html - 主页(将引用styles.css)
3. about.html - 关于页(将引用styles.css)
4. projects.html - 项目页(将引用styles.css)
5. contact.html - 联系页(将引用styles.css)

此顺序确保在创建需要依赖项的文件之前,所有依赖项都已准备就绪。"

然后严格按此顺序创建文件。
❌ 错误 - 请勿这样做:
用户:"创建一个包含主页、关于页、项目页和联系页的作品集网站"

[未经思考立即创建index.html]
[创建about.html]
[创建projects.html]
[意识到应该共享CSS,不得不回头添加]

这会浪费精力和上下文!
✅ 正确 - 应该这样做:
用户:"创建一个包含主页、关于页、项目页和联系页的作品集网站"

"深度思考架构..." [先规划]
"我将按以下顺序创建:先创建CSS,然后创建HTML页面" [宣布规划]
[创建styles.css]
[创建引用styles.css的HTML页面]

高效完成!无冗余工作!

Workflow 1: Complex Decision Making

工作流1:复杂决策

With Thinking Delegation:
Claude Code:
User: "Should we use microservices or monolith?"

1. /agent deep-analyzer "Ultrathink about architecture choice 
   for 10M user e-commerce platform, 8 dev team"
2. [Receives well-reasoned recommendation in main context]
3. Make decision based on analysis
4. Proceed with implementation
Web/API:
User: "Should we use microservices or monolith?"

1. "Create a deep-analysis.md artifact and ultrathink about this"
2. [Artifact contains extended thinking + conclusion]
3. Main conversation: "Based on analysis, recommend monolith because..."
4. Proceed with implementation
Context efficiency: Deep thinking happens, main context stays clean.

使用思考委托:
Claude Code:
用户:"我们应该使用微服务还是单体架构?"

1. /agent deep-analyzer "极致思考架构选择
   针对1000万用户的电商平台,8人开发团队"
2. [在主上下文中收到经过充分推理的建议]
3. 根据分析做出决策
4. 继续实现
Web/API:
用户:"我们应该使用微服务还是单体架构?"

1. "创建deep-analysis.md artifact并极致思考此问题"
2. [Artifact包含扩展思考 + 结论]
3. 主对话:"根据分析,推荐单体架构,因为..."
4. 继续实现
上下文效率: 进行深度思考,同时主上下文保持清洁。

Workflow 2: Complex Feature Development

工作流2:复杂功能开发

Phase 1: Architecture Analysis
Claude Code: /agent deep-analyzer "Think deeply about architecture for [feature]"
Web/API: "Create architecture-analysis artifact with deep thinking"
[Isolated thinking → summary to main]

Phase 2: Design Planning
"Based on that analysis, create implementation plan artifact"
[Main context references analysis conclusions]

Phase 3: Implementation
"Implement component A based on the plan"
[Create code artifact]

Phase 4: Testing
Claude Code: /agent test-runner "Run tests and analyze failures"
Web/API: "Run tests" [test output in separate space]

Phase 5: Integration
"Integrate based on architecture plan"
Why it works: Each phase has clear purpose, thinking isolated where needed.

阶段1:架构分析
Claude Code:/agent deep-analyzer "深入思考[功能]的架构"
Web/API:"创建architecture-analysis artifact并深度思考"
[隔离思考 → 摘要返回主上下文]

阶段2:设计规划
"基于该分析,创建实现规划artifact"
[主上下文参考分析结论]

阶段3:实现
"基于规划实现组件A"
[创建代码artifact]

阶段4:测试
Claude Code:/agent test-runner "运行测试并分析失败原因"
Web/API:"运行测试" [测试输出在单独空间]

阶段5:集成
"基于架构规划进行集成"
为什么有效: 每个阶段都有明确的目标,思考在需要时被隔离。

Workflow 3: Research & Technology Evaluation

工作流3:研究与技术评估

Phase 1: Deep Research
Claude Code: /agent pattern-researcher "Research and think hard about 
  authentication approaches, analyze tradeoffs"
Web/API: "Create research-findings artifact and think through options"

Phase 2: Synthesis
[Receives summary of findings]
"Create comparison table artifact"

Phase 3: Recommendation
Claude Code: /agent deep-analyzer "Based on research, recommend approach"
Web/API: "Based on research artifact, ultrathink and recommend"

Phase 4: Implementation
"Implement recommended approach"
Why it works: Research and deep analysis isolated, implementation focused.

阶段1:深度研究
Claude Code:/agent pattern-researcher "研究并深度思考
  认证方法,分析权衡"
Web/API:"创建research-findings artifact并思考各种选项"

阶段2:综合
[收到发现摘要]
"创建对比表格artifact"

阶段3:推荐
Claude Code:/agent deep-analyzer "基于研究,推荐方法"
Web/API:"基于研究artifact,极致思考并推荐"

阶段4:实现
"实现推荐的方法"
为什么有效: 研究和深度分析被隔离,实现保持聚焦。

Workflow 4: Code Generation & Iteration

工作流4:代码生成与迭代

1. "Create a [language] script that [functionality]"
   → Artifact created

2. "Add [feature] to the script"
   → Artifact updated

3. "Optimize the [specific part]"
   → Targeted update

4. "Add error handling"
   → Incremental improvement
Why it works: All code lives in the artifact, conversation stays focused on what to change.

1. "创建一个[语言]脚本artifact,实现[功能]"
   → 创建artifact

2. "向脚本添加[功能]"
   → 更新artifact

3. "优化[特定部分]"
   → 针对性更新

4. "添加错误处理"
   → 增量改进
为什么有效: 所有代码存储在artifact中,对话聚焦于需要更改的内容。

Workflow 5: Refactoring with Analysis

工作流5:带分析的重构

Claude Code:
1. /agent analyzer "Think hard about refactoring approach 
   for legacy auth system"
2. [Receives analysis in main: strategy, risks, order]
3. "Create REFACTOR.md plan based on analysis"
4. /clear
5. For each module:
   - Refactor according to plan
   - /agent test-runner "verify changes"
   - Commit
   - /clear before next
Web/API:
1. "Create refactoring-analysis artifact, think deeply about approach"
2. [Artifact has thinking + strategy]
3. "Create refactoring-plan artifact based on analysis"
4. Implement module by module
5. Reference plan artifact as you work
Why it works: Deep analysis happens once (isolated), execution follows clean plan.
Claude Code:
1. /agent analyzer "深度思考遗留认证系统的重构方法"
2. [在主上下文中收到分析:策略、风险、顺序]
3. "基于分析创建REFACTOR.md规划"
4. /clear
5. 针对每个模块:
   - 根据规划重构
   - /agent test-runner "验证更改"
   - 提交
   - 下一个模块前执行/clear
Web/API:
1. "创建refactoring-analysis artifact,深入思考方法"
2. [Artifact包含思考 + 策略]
3. "基于分析创建refactoring-plan artifact"
4. 逐个模块实现
5. 工作时参考规划artifact
为什么有效: 深度分析仅进行一次(隔离),执行遵循清晰的规划。

Best Practices (Universal)

最佳实践(通用)

1. Delegate Complex Analysis to Isolated Contexts

1. 将复杂分析委托给隔离上下文

The most powerful pattern for context efficiency:
Claude Code:
✅ /agent deep-analyzer "Ultrathink about [complex decision]"
❌ "Think about [complex decision]" [happens in main context]
Web/API:
✅ "Create analysis artifact and ultrathink about [decision]"
❌ "Ultrathink about [decision]" [thinking stays in conversation]
Benefit: 5K+ tokens of reasoning happens in isolation, main context receives ~200 token summary. 23x context efficiency while maintaining analytical depth.
上下文效率最高的模式:
Claude Code:
✅ /agent deep-analyzer "极致思考[复杂决策]"
❌ "思考[复杂决策]" [在主上下文中进行]
Web/API:
✅ "创建分析artifact并极致思考[决策]"
❌ "极致思考[决策]" [思考保留在对话中]
优势: 5000+令牌的推理在隔离环境中进行,主上下文仅接收~200令牌的摘要。在保持分析深度的同时,上下文效率提升23倍。

2. Use Extended Thinking for Planning

2. 规划时使用扩展思考

Before diving into implementation:
"think hard about the approach for [task]"
Even better with delegation:
  • Claude Code: Delegate to deep_analyzer subagent
  • Web/API: Use thinking artifact
Benefit: Reasoning stays out of main context, you get thoughtful plans.
在开始实现之前:
"深度思考[任务]的方法"
委托效果更佳:
  • Claude Code:委托给deep_analyzer子代理
  • Web/API:使用思考artifact
优势: 推理不进入主上下文,你可获得深思熟虑的规划。

3. Create Artifacts for Substantial Content

3. 为大量内容创建Artifact

Don't inline long code or documents in conversation:
✅ "Create a Python script artifact that [functionality]"
❌ "Show me the Python code for [functionality]"
Benefit: Content lives in artifacts, not conversation history.
不要在对话中内联长代码或文档:
✅ "创建一个Python脚本artifact,实现[功能]"
❌ "展示实现[功能]的Python代码"
优势: 内容存储在artifact中,而非对话历史。

4. Break Complex Tasks Into Explicit Phases

4. 将复杂任务拆分为明确的阶段

State phase transitions clearly:
"Phase 1 complete. Moving to Phase 2: [description]"
With thinking delegation:
Phase 1: /agent deep-analyzer "analyze approaches"
Phase 2: Implement based on analysis
Benefit: Each phase has clear purpose and boundaries.
明确说明阶段转换:
"阶段1完成。进入阶段2:[描述]"
结合思考委托:
阶段1:/agent deep-analyzer "分析方法"
阶段2:基于分析实现
优势: 每个阶段都有明确的目标和边界。

5. Document Decisions in Artifacts

5. 在Artifact中记录决策

Create persistent references:
"Create a decisions.md artifact tracking our key choices"
Benefit: Can reference decisions without re-explaining full context.
创建持久引用:
"创建decisions.md artifact记录我们的关键选择"
优势: 无需重新解释完整上下文即可参考决策。

6. Progressive Disclosure

6. 渐进式披露

Don't request everything at once:
✅ "First, analyze the requirements"
    "Now, design the data model"
    "Now, implement the core logic"

❌ "Analyze requirements, design data model, and implement everything"
Benefit: Each step builds on the last without overwhelming context.
不要一次性请求所有内容:
✅ "首先,分析需求"
    "现在,设计数据模型"
    "现在,实现核心逻辑"

❌ "分析需求、设计数据模型并实现所有内容"
优势: 每个步骤基于上一步构建,不会使上下文过载。

7. Use Thinking for Exploration

7. 使用思考进行探索

When uncertain about approach:
"ultrathink about multiple approaches and recommend the best one"
Even better: Delegate to deep_analyzer (Claude Code) or thinking artifact (Web/API)
Benefit: Deep analysis without context clutter.
不确定方法时:
"极致思考多种方法并推荐最佳方案"
更好的方式: 委托给deep_analyzer(Claude Code)或使用思考artifact(Web/API)
优势: 无需使上下文混乱即可进行深度分析。

8. Signal Context Resets

8. 表示上下文重置

When changing direction:
"Setting aside the previous approach, let's try a different angle..."
Benefit: Clear boundaries prevent old context from interfering.
改变方向时:
"抛开之前的方法,让我们尝试不同的角度..."
优势: 清晰的边界可防止旧上下文干扰。

Advanced Patterns (Universal)

高级模式(通用)

Pattern: Iterative Refinement

模式:迭代细化

1. "Create initial version of [artifact]"
2. Review
3. "Improve [specific aspect]"
4. Review
5. "Add [feature]"
6. Continue iterating
Benefit: Focused improvements, not recreating everything each time.
1. "创建[artifact]的初始版本"
2. 审核
3. "改进[特定方面]"
4. 审核
5. "添加[功能]"
6. 继续迭代
优势: 聚焦于改进,而非每次重新创建所有内容。

Pattern: Multi-Artifact Projects

模式:多Artifact项目

1. "Create architecture.md artifact"
2. "Create database-schema.sql artifact"
3. "Create api-spec.yaml artifact"
4. "Now implement based on these artifacts"
Benefit: Each artifact is a stable reference, no context accumulation.
1. "创建architecture.md artifact"
2. "创建database-schema.sql artifact"
3. "创建api-spec.yaml artifact"
4. "现在基于这些artifact实现"
优势: 每个artifact都是稳定的参考,不会累积上下文。

Pattern: Thinking → Document → Execute

模式:思考 → 记录 → 执行

1. "ultrathink about [complex problem]"
2. "Document the decision in a plan artifact"
3. "Execute phase 1 of the plan"
4. Reference plan artifact as you continue
Benefit: Separation of reasoning, planning, and execution.
1. "极致思考[复杂问题]"
2. "在规划artifact中记录决策"
3. "执行规划的第1阶段"
4. 继续时参考规划artifact
优势: 推理、规划和执行分离。

Pattern: Chunked Content Generation

模式:分块内容生成

For long documents:
1. "Create outline artifact"
2. "Write introduction (add to artifact)"
3. "Write section 1 (add to artifact)"
4. Continue section by section
Benefit: Build progressively without loading entire document context each time.

针对长文档:
1. "创建大纲artifact"
2. "撰写引言(添加到artifact)"
3. "撰写第1节(添加到artifact)"
4. 继续逐节撰写
优势: 逐步构建,无需每次加载整个文档上下文。

🔧 PART 2: CLI-SPECIFIC FEATURES (Claude Code Users Only)

🔧 第二部分:CLI特定功能(仅Claude Code用户)

The sections below are ONLY for users of Claude Code CLI. Web and API users can skip this part.

以下部分仅适用于Claude Code CLI用户。Web和API用户可跳过此部分。

Claude Code Tooling (Bonus Features)

Claude Code工具(附加功能)

When using Claude Code CLI, additional optimization tools are available:
使用Claude Code CLI时,可使用额外的优化工具:

Quick Start: Generate CLAUDE.md

快速入门:生成CLAUDE.md

Create a context-optimized CLAUDE.md file for your project:
bash
python scripts/generate_claude_md.py --type [TYPE] --output ./CLAUDE.md
Available types:
  • general
    - General-purpose projects
  • backend
    - API/service projects
  • frontend
    - Web applications
  • fullstack
    - Full-stack applications
  • data
    - Data science/ML projects
  • library
    - Library/package development
What it does: Generates a CLAUDE.md file that Claude Code reads automatically, providing persistent project guidance across sessions.
为你的项目创建上下文优化的CLAUDE.md文件:
bash
python scripts/generate_claude_md.py --type [TYPE] --output ./CLAUDE.md
可用类型:
  • general
    - 通用项目
  • backend
    - API/服务项目
  • frontend
    - Web应用
  • fullstack
    - 全栈应用
  • data
    - 数据科学/ML项目
  • library
    - 库/包开发
功能: 生成Claude Code自动读取的CLAUDE.md文件,跨会话提供持久的项目指导。

Create Subagents

创建子代理

For recurring tasks, create dedicated subagents:
bash
python scripts/create_subagent.py [NAME] --type [TYPE] --output [DIR]
Available types:
  • researcher
    - Documentation searches with deep analysis
  • tester
    - Test execution with failure analysis
  • analyzer
    - Code analysis with architectural insights
  • builder
    - Build and deployment tasks
  • deep_analyzer
    - Complex decisions requiring extensive thinking (recommended for architecture, tech choices, design patterns)
What it does: Creates
.claude/agents/[NAME].md
configuration that can be invoked with:
/agent [NAME] [task description]
为重复任务创建专用子代理:
bash
python scripts/create_subagent.py [NAME] --type [TYPE] --output [DIR]
可用类型:
  • researcher
    - 带深度分析的文档搜索
  • tester
    - 带失败分析的测试执行
  • analyzer
    - 带架构洞察的代码分析
  • builder
    - 构建和部署任务
  • deep_analyzer
    - 需要大量思考的复杂决策(推荐用于架构、技术选择、设计模式)
功能: 创建
.claude/agents/[NAME].md
配置,可通过以下命令调用:
/agent [NAME] [任务描述]

Claude Code Commands

Claude Code命令

  • /clear
    - Reset context between tasks
  • /compact
    - Compress context while preserving key decisions
  • /continue
    - Resume previous session
  • /agent [NAME]
    - Delegate task to a subagent with isolated context
  • /clear
    - 任务间重置上下文
  • /compact
    - 压缩上下文,同时保留关键决策
  • /continue
    - 恢复之前的会话
  • /agent [NAME]
    - 将任务委托给带隔离上下文的子代理

Claude Code Patterns

Claude Code模式

Pattern: Deep Analysis Delegation
1. /clear (start fresh)
2. /agent deep-analyzer "Ultrathink about [complex decision]"
3. [Receives well-reasoned analysis in ~200 tokens]
4. Make decision and implement
5. Main context stayed clean throughout
Pattern: Research with Thinking
1. /agent pattern-researcher "Research [topic] and think hard about implications"
2. [Subagent searches + thinks in isolation]
3. Review findings in main context
4. Proceed with informed decision
Pattern: Test-Driven Development with Analysis
1. Write test in main context
2. /agent test-runner "Run test and think hard if it fails"
3. [Subagent analyzes root cause in isolation]
4. Implement fix based on analysis
5. /agent test-runner "verify"
6. If passing: commit and /clear
Pattern: Architecture Evolution
1. /agent analyzer "Think deeply about current architecture issues"
2. [Receives analysis: bottlenecks, technical debt, opportunities]
3. /agent deep-analyzer "Recommend evolution strategy"
4. Create EVOLUTION.md plan
5. /clear
6. Execute plan phase by phase
Pattern: Large Refactoring with Thinking
1. /agent analyzer "Think hard about refactoring scope and risks"
2. [Receives risk assessment + strategy]
3. Create REFACTOR.md plan
4. /clear
5. For each file:
   - Load and refactor
   - /agent test-runner "analyze test results"
   - /clear before next
For detailed Claude Code patterns, see references/subagent_patterns.md and references/context_strategies.md.
模式:深度分析委托
1. /clear(重新开始)
2. /agent deep-analyzer "极致思考[复杂决策]"
3. [收到约200令牌的经过充分推理的分析]
4. 做出决策并实现
5. 主上下文全程保持清洁
模式:带思考的研究
1. /agent pattern-researcher "研究[主题]并深度思考其影响"
2. [子代理在隔离环境中搜索 + 思考]
3. 在主上下文中审核发现
4. 基于知情决策继续
模式:带分析的测试驱动开发
1. 在主上下文中编写测试
2. /agent test-runner "运行测试并深度思考失败原因"
3. [子代理在隔离环境中分析根本原因]
4. 基于分析实现修复
5. /agent test-runner "验证"
6. 如果通过:提交并执行/clear
模式:架构演进
1. /agent analyzer "深入思考当前架构问题"
2. [收到分析:瓶颈、技术债务、机会]
3. /agent deep-analyzer "推荐演进策略"
4. 创建EVOLUTION.md规划
5. /clear
6. 分阶段执行规划
模式:带思考的大型重构
1. /agent analyzer "深度思考重构范围和风险"
2. [收到风险评估 + 策略]
3. 创建REFACTOR.md规划
4. /clear
5. 针对每个文件:
   - 加载并重构
   - /agent test-runner "分析测试结果"
   - 下一个文件前执行/clear
有关详细的Claude Code模式,请参阅references/subagent_patterns.mdreferences/context_strategies.md

Troubleshooting (All Environments)

故障排除(所有环境)

"Responses are getting less focused"

"响应变得不聚焦"

Symptoms: Claude references old, irrelevant information or responses drift off topic.
Solutions:
  • Web/API: Explicitly state "Setting aside previous discussion, let's focus on..."
  • Claude Code: Use
    /clear
    or
    /compact
  • Universal: Break task into new phases with clear boundaries
症状: Claude引用旧的、无关的信息,或偏离主题。
解决方案:
  • Web/API: 明确表示"抛开之前的讨论,我们专注于..."
  • Claude Code: 使用
    /clear
    /compact
  • 通用: 将任务拆分为带清晰边界的新阶段

"Complex task feels overwhelming"

"复杂任务感觉不堪重负"

Symptoms: Unsure where to start, too many moving parts.
Solutions:
  1. "think harder about breaking this into phases"
  2. Create a planning artifact
  3. Execute one phase at a time
  4. Reference plan artifact as you go
症状: 不确定从哪里开始,有太多可移动部件。
解决方案:
  1. "更深入地思考如何将其拆分为多个阶段"
  2. 创建规划artifact
  3. 一次执行一个阶段
  4. 工作时参考规划artifact

"Conversation getting too long"

"对话变得太长"

Symptoms: Long history, hard to track what's been decided.
Solutions:
  • Web/API: Create a "decisions.md" artifact to summarize key points
  • Claude Code: Use
    /compact
    to compress history
  • Universal: Start a new conversation with "Previously we decided X, Y, Z. Now let's..."
症状: 历史记录过长,难以跟踪已做出的决策。
解决方案:
  • Web/API: 创建"decisions.md" artifact总结关键点
  • Claude Code: 使用
    /compact
    压缩历史记录
  • 通用: 开始新对话,说明"之前我们决定了X、Y、Z。现在我们..."

"Need to maintain context across sessions"

"需要跨会话维护上下文"

Symptoms: Have to re-explain everything each time.
Solutions:
  • Create artifacts documenting key decisions and context
  • Claude Code: Use CLAUDE.md for persistent project memory
  • Start new sessions with: "Continuing from previous work where we [brief summary]"
症状: 每次都要重新解释所有内容。
解决方案:
  • 创建artifact记录关键决策和上下文
  • Claude Code: 使用CLAUDE.md实现持久项目记忆
  • 开始新会话时说明:"继续之前的工作,我们...[简要摘要]"

"Code keeps being regenerated instead of edited"

"代码不断被重新生成,而非编辑"

Symptoms: Small changes result in entire code rewrites.
Solutions:
  1. Use artifacts for code
  2. Request specific edits: "Update the handle_request function to add validation"
  3. Don't say "show me the code again" - reference the existing artifact
症状: 小更改导致整个代码重写。
解决方案:
  1. 使用artifact存储代码
  2. 请求特定编辑:"更新handle_request函数以添加验证"
  3. 不要说"再次展示代码" - 引用现有的artifact

"Responses include too much explanation"

"响应包含太多解释"

Symptoms: Getting lengthy explanations when you just want output.
Solutions:
  • Be explicit: "Just create the artifact, minimal explanation"
  • "Output only, no commentary"
  • "Concise response please"
症状: 你只想要输出,却收到冗长的解释。
解决方案:
  • 明确要求:"只需创建artifact,尽量少解释"
  • "仅输出,无需评论"
  • "请简洁响应"

"Extended thinking not being used"

"未使用扩展思考"

Symptoms: Jumping straight to solutions without analysis.
Solutions:
  • Explicitly request: "think hard about..."
  • Use stronger triggers: "ultrathink about..."
  • Ask for planning: "think about multiple approaches"
症状: 直接跳到解决方案,未进行分析。
解决方案:
  • 明确请求:"深度思考..."
  • 使用更强的触发器:"极致思考..."
  • 请求规划:"思考多种方法"

Reference Documentation

参考文档

For deeper understanding, consult the reference files:
  • references/context_strategies.md - Comprehensive workflows and scenario-based strategies (includes Claude Code specific strategies)
  • references/subagent_patterns.md - Detailed subagent usage patterns for Claude Code users
Load these when you need:
  • Scenario-based workflow guidance
  • Advanced context management techniques
  • Claude Code-specific patterns
  • Troubleshooting complex context issues
如需深入了解,请查阅参考文件:
  • references/context_strategies.md - 全面的工作流和基于场景的策略(包含Claude Code特定策略)
  • references/subagent_patterns.md - 针对Claude Code用户的详细子代理使用模式
当你需要以下内容时加载这些文件:
  • 基于场景的工作流指导
  • 高级上下文管理技术
  • Claude Code特定模式
  • 复杂上下文问题的故障排除

Scripts Reference (Claude Code Users)

脚本参考(Claude Code用户)

generate_claude_md.py

generate_claude_md.py

Generate project-specific CLAUDE.md files:
bash
python scripts/generate_claude_md.py --type TYPE --output PATH
Options:
  • --type
    : Project type (general, backend, frontend, fullstack, data, library)
  • --output
    : Output path (default: ./CLAUDE.md)
生成项目特定的CLAUDE.md文件:
bash
python scripts/generate_claude_md.py --type TYPE --output PATH
选项:
  • --type
    : 项目类型(general、backend、frontend、fullstack、data、library)
  • --output
    : 输出路径(默认:./CLAUDE.md)

create_subagent.py

create_subagent.py

Create subagent configurations:
bash
python scripts/create_subagent.py NAME --type TYPE --output DIR
Options:
  • NAME
    : Agent name (e.g., test-runner, doc-searcher)
  • --type
    : Agent type (researcher, tester, analyzer, builder)
  • --output
    : Output directory (default: current directory)
创建子代理配置:
bash
python scripts/create_subagent.py NAME --type TYPE --output DIR
选项:
  • NAME
    : 代理名称(如test-runner、doc-searcher)
  • --type
    : 代理类型(researcher、tester、analyzer、builder)
  • --output
    : 输出目录(默认:当前目录)

Getting the Most from This Skill

充分利用本技能

For All Claude Users:

针对所有Claude用户:

  1. Delegate complex analysis - Use thinking delegation architecture
    • Web/API: Create analysis artifacts for deep thinking
    • Claude Code: Use deep_analyzer subagent for decisions
  2. Use extended thinking liberally - "think hard" for planning, but delegate when possible
  3. Create artifacts for substantial content - Keep conversation focused
  4. Break tasks into explicit phases - Clear boundaries prevent context sprawl
  5. Document decisions in artifacts - Persistent references you can return to
  1. 委托复杂分析 - 使用思考委托架构
    • Web/API:为深度思考创建分析artifact
    • Claude Code:使用deep_analyzer子代理进行决策
  2. 大量使用扩展思考 - "深度思考"用于规划,但尽可能委托
  3. 为大量内容创建artifact - 保持对话聚焦
  4. 将任务拆分为明确的阶段 - 清晰的边界防止上下文扩散
  5. 在artifact中记录决策 - 可返回参考的持久引用

For Claude Code Users (Additional):

针对Claude Code用户(附加):

  1. Create thinking-enabled subagents immediately:
    bash
    python scripts/create_subagent.py architecture-advisor --type deep_analyzer
    python scripts/create_subagent.py pattern-researcher --type researcher
    python scripts/create_subagent.py code-analyzer --type analyzer
    python scripts/create_subagent.py test-analyzer --type tester
  2. Generate CLAUDE.md for each project - Persistent project memory
  3. Practice thinking delegation -
    /agent deep-analyzer
    for complex decisions
  4. Use
    /clear
    between major tasks
    - Start each task fresh
  5. Monitor context usage - Claude reports remaining tokens
  1. 立即创建支持思考的子代理:
    bash
    python scripts/create_subagent.py architecture-advisor --type deep_analyzer
    python scripts/create_subagent.py pattern-researcher --type researcher
    python scripts/create_subagent.py code-analyzer --type analyzer
    python scripts/create_subagent.py test-analyzer --type tester
  2. 为每个项目生成CLAUDE.md - 持久项目记忆
  3. 练习思考委托 -
    /agent deep-analyzer
    用于复杂决策
  4. 在主要任务间使用
    /clear
    - 每个任务重新开始
  5. 监控上下文使用 - Claude会报告剩余令牌

Activation Tips:

激活技巧:

This skill activates automatically for complex queries, but you can explicitly invoke it:
  • "Help me manage context for this task"
  • "What's the best approach to keep context efficient?"
  • "Analyze this decision deeply but keep context clean"
  • "Think deeply about this" (will suggest delegation)
本技能会针对复杂查询自动激活,但你也可以显式调用它:
  • "帮助我管理此任务的上下文"
  • "保持上下文高效的最佳方法是什么?"
  • "深入分析此决策,但保持上下文清洁"
  • "深入思考此问题"(会建议委托)

Measuring Success:

衡量成功:

Signs thinking delegation is working:
  • Complex decisions made with minimal main context usage
  • Multiple analyses in single session without context bloat
  • Clear, well-reasoned recommendations without verbose explanations
  • Can sustain 10+ complex analyses in one session
Context efficiency metrics:
  • Traditional: ~7K tokens per complex analysis
  • With delegation: ~300 tokens per complex analysis
  • Target: 20+ analyses per 200K context window
The goal is sustainable, high-quality Claude interactions that maintain performance and analytical depth regardless of task complexity or conversation length.
思考委托有效的迹象:
  • 复杂决策的主上下文使用量极少
  • 单会话中可进行多次分析而无上下文膨胀
  • 无需冗长解释即可获得清晰、经过充分推理的建议
  • 单会话中可进行10+次复杂分析
上下文效率指标:
  • 传统:每次复杂分析约7000令牌
  • 使用委托:每次复杂分析约300令牌
  • 目标: 每个200K上下文窗口可进行20+次分析
我们的目标是实现可持续、高质量的Claude交互,无论任务复杂度或对话长度如何,都能保持性能和分析深度。