pro-workflow

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Pro Workflow

专业工作流

Real-world Claude Code patterns from power users who ship production code daily. Not theory - workflows that compound over time.
来自每天交付生产代码的资深用户的真实Claude Code模式。绝非理论——这些工作流会随时间不断优化。

The Core Insight

核心洞察

"80% of my code is written by AI, 20% is spent reviewing and correcting it." — Karpathy
This skill optimizes for that ratio. Every pattern here reduces correction cycles.

"我80%的代码由AI编写,20%的时间用于审查和修正。" ——卡帕西
本技能正是为优化这一比例而设计。这里的每一种模式都能减少修正周期。

1. The Self-Correction Loop

1. 自修正循环

The single most powerful pattern. Your CLAUDE.md trains itself through corrections.
最强大的单一模式。你的CLAUDE.md会通过修正实现自我训练。

How It Works

工作原理

When you correct Claude:
  1. Claude acknowledges the mistake
  2. Proposes a rule to prevent it
  3. You approve → rule goes into memory
  4. Future sessions avoid the same mistake
当你修正Claude时:
  1. Claude会明确承认错误
  2. 提出一条避免再犯的规则
  3. 你批准后,规则将存入记忆
  4. 后续会话中会避免相同错误

Add to CLAUDE.md

添加至CLAUDE.md

markdown
undefined
markdown
undefined

Self-Correction Protocol

Self-Correction Protocol

When the user corrects me or I make a mistake:
  1. Acknowledge specifically what went wrong
  2. Propose a concise rule:
    [LEARN] Category: One-line rule
  3. Wait for approval before adding to LEARNED section
When the user corrects me or I make a mistake:
  1. Acknowledge specifically what went wrong
  2. Propose a concise rule:
    [LEARN] Category: One-line rule
  3. Wait for approval before adding to LEARNED section

LEARNED

LEARNED

<!-- Auto-populated through corrections -->
undefined
<!-- Auto-populated through corrections -->
undefined

Trigger Phrases

触发短语

  • "Add that to your rules"
  • "Remember this"
  • "Don't do that again"
  • "Add that to your rules"
  • "Remember this"
  • "Don't do that again"

Example Flow

示例流程

User: You edited the wrong file
Claude: I edited src/utils.ts when you meant src/lib/utils.ts.

[LEARN] Navigation: Confirm full path before editing files with common names.

Should I add this?

User: You edited the wrong file
Claude: I edited src/utils.ts when you meant src/lib/utils.ts.

[LEARN] Navigation: Confirm full path before editing files with common names.

Should I add this?

2. Parallel Sessions with Worktrees

2. 基于工作树的并行会话

Zero dead time. While one Claude thinks, work on something else.
零等待时间。当一个Claude在思考时,你可以处理其他任务。

Setup

设置步骤

bash
undefined
bash
undefined

Create worktrees for parallel work

创建用于并行工作的工作树

git worktree add ../project-feat feature-branch git worktree add ../project-fix bugfix-branch
git worktree add ../project-feat feature-branch git worktree add ../project-fix bugfix-branch

Each gets its own Claude session

每个工作树对应独立的Claude会话

Terminal 1: cd ~/project && claude

终端1: cd ~/project && claude

Terminal 2: cd ~/project-feat && claude

终端2: cd ~/project-feat && claude

undefined
undefined

When to Parallelize

适用并行场景

ScenarioAction
Waiting on testsStart new feature in worktree
Long buildDebug issue in parallel
Exploring approachesTry 2-3 simultaneously
场景操作
等待测试结果在工作树中启动新功能开发
构建耗时较长并行调试问题
探索多种方案同时尝试2-3种思路

Add to CLAUDE.md

添加至CLAUDE.md

markdown
undefined
markdown
undefined

Parallel Work

Parallel Work

When blocked on long operations, suggest starting a parallel session in a worktree.

---
When blocked on long operations, suggest starting a parallel session in a worktree.

---

3. The Wrap-Up Ritual

3. 收尾流程

End sessions with intention. Capture learnings, verify state.
有目的地结束会话。捕获经验,验证状态。

/wrap-up Checklist

/wrap-up 检查清单

  1. Changes Audit - List modified files, uncommitted changes
  2. State Check - Run
    git status
    , tests, lint
  3. Learning Capture - What mistakes? What worked?
  4. Next Session - What's next? Any blockers?
  5. Summary - One paragraph of what was accomplished
  1. 变更审计 - 列出修改的文件、未提交的变更
  2. 状态检查 - 运行
    git status
    、测试、代码检查
  3. 经验捕获 - 犯了哪些错误?哪些方法有效?
  4. 下一会话规划 - 接下来要做什么?有哪些障碍?
  5. 总结 - 用一段话概括完成的工作

Create Command

创建命令

~/.claude/commands/wrap-up.md
:
markdown
Execute wrap-up checklist:
1. `git status` - uncommitted changes?
2. `npm test -- --changed` - tests passing?
3. What was learned this session?
4. Propose LEARNED additions
5. One-paragraph summary

~/.claude/commands/wrap-up.md
:
markdown
Execute wrap-up checklist:
1. `git status` - uncommitted changes?
2. `npm test -- --changed` - tests passing?
3. What was learned this session?
4. Propose LEARNED additions
5. One-paragraph summary

4. Split Memory Architecture

4. 拆分式记忆架构

For complex projects, modularize Claude memory.
针对复杂项目,模块化Claude的记忆。

Structure

结构

.claude/
├── CLAUDE.md        # Entry point
├── AGENTS.md        # Workflow rules
├── SOUL.md          # Style preferences
└── LEARNED.md       # Auto-populated
.claude/
├── CLAUDE.md        # 入口文件
├── AGENTS.md        # 工作流规则
├── SOUL.md          # 风格偏好
└── LEARNED.md       # 自动填充

AGENTS.md

AGENTS.md

markdown
undefined
markdown
undefined

Workflow Rules

Workflow Rules

Planning

Planning

Plan mode when: >3 files, architecture decisions, multiple approaches.
Plan mode when: >3 files, architecture decisions, multiple approaches.

Quality Gates

Quality Gates

Before complete: lint, typecheck, test --related.
Before complete: lint, typecheck, test --related.

Subagents

Subagents

Use for: parallel exploration, background tasks. Avoid for: tasks needing conversation context.
undefined
Use for: parallel exploration, background tasks. Avoid for: tasks needing conversation context.
undefined

SOUL.md

SOUL.md

markdown
undefined
markdown
undefined

Style

Style

  • Concise over verbose
  • Action over explanation
  • Acknowledge mistakes directly
  • No features beyond scope

---
  • Concise over verbose
  • Action over explanation
  • Acknowledge mistakes directly
  • No features beyond scope

---

5. The 80/20 Review Pattern

5. 80/20审查模式

Batch reviews at checkpoints, not every change.
在检查点批量审查,而非每次变更都审查。

Review Points

审查节点

  1. After plan approval
  2. After each milestone
  3. Before destructive operations
  4. At /wrap-up
  1. 计划批准后
  2. 每个里程碑完成后
  3. 执行破坏性操作前
  4. /wrap-up阶段

Add to CLAUDE.md

添加至CLAUDE.md

markdown
undefined
markdown
undefined

Review Checkpoints

Review Checkpoints

Pause for review at: plan completion, >5 file edits, git operations, auth/security code. Between: proceed with confidence.

---
Pause for review at: plan completion, >5 file edits, git operations, auth/security code. Between: proceed with confidence.

---

6. Model Selection

6. 模型选择

Opus 4.6 with adaptive thinking calibrates reasoning depth automatically.
TaskModel
Quick fixesHaiku 4.5
FeaturesSonnet 4.5
RefactorsOpus 4.6
ArchitectureOpus 4.6 + Extended Thinking
Hard bugsOpus 4.6 + Extended Thinking
Opus 4.6 自适应思考可根据任务自动调整推理深度。
任务模型
快速修复Haiku 4.5
功能开发Sonnet 4.5
代码重构Opus 4.6
架构设计Opus 4.6 + 扩展思考
疑难bug排查Opus 4.6 + 扩展思考

Adaptive Thinking

自适应思考

Opus 4.6 automatically calibrates reasoning depth per task - lightweight for simple operations, deep analysis for complex problems. No configuration needed.
Opus 4.6会根据任务自动调整推理深度——简单操作使用轻量模式,复杂问题使用深度分析。无需额外配置。

Add to CLAUDE.md

添加至CLAUDE.md

markdown
undefined
markdown
undefined

Model Hints

Model Hints

Escalate to Opus+Thinking when: first attempt failed, multi-system coordination, non-obvious bugs. Use subagents with Haiku for fast read-only exploration, Sonnet for balanced work.

---
Escalate to Opus+Thinking when: first attempt failed, multi-system coordination, non-obvious bugs. Use subagents with Haiku for fast read-only exploration, Sonnet for balanced work.

---

7. Context Discipline

7. 上下文管理规范

200k tokens is precious. Manage it.
20万token十分宝贵,需合理管理。

Rules

规则

  1. Read before edit
  2. Compact at task boundaries
  3. Disable unused MCPs (<10 enabled, <80 tools)
  4. Summarize explorations
  5. Use subagents to isolate high-volume output (tests, logs, docs)
  1. 先阅读再编辑
  2. 在任务边界处压缩上下文
  3. 禁用未使用的MCP(启用数量<10,工具总数<80)
  4. 总结探索过程
  5. 使用子代理隔离高容量输出(测试、日志、文档)

Context Compaction

上下文压缩

  • Auto-compacts at ~95% capacity (keeps long-running agents alive)
  • Configure earlier compaction:
    CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50
  • Use PreCompact hooks to save state before compaction
  • Subagents auto-compact independently from the main session
  • 当容量达到~95%时自动压缩(保持长期运行的代理存活)
  • 可配置更早的压缩阈值:
    CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=50
  • 使用PreCompact钩子在压缩前保存状态
  • 子代理独立于主会话自动压缩

Good Compact Points

合适的压缩节点

  • After planning, before execution
  • After completing a feature
  • When context >70%
  • Before switching task domains

  • 规划完成后,执行前
  • 功能开发完成后
  • 上下文占用>70%
  • 切换任务领域前

8. Learning Log

8. 学习日志

Auto-document insights from sessions.
自动记录会话中的洞察。

Add to CLAUDE.md

添加至CLAUDE.md

markdown
undefined
markdown
undefined

Learning Log

Learning Log

After tasks, note learnings:
[DATE] [TOPIC]: Key insight
Append to .claude/learning-log.md

---
After tasks, note learnings:
[DATE] [TOPIC]: Key insight
Append to .claude/learning-log.md

---

Learn Claude Code

学习Claude Code

Master Claude Code through built-in best practices and official documentation.
Pro-workflow teaches Claude Code concepts directly and links to official docs at https://code.claude.com/docs/ for deep dives.
通过内置最佳实践和官方文档掌握Claude Code。
专业工作流直接教授Claude Code概念,并链接至官方文档**https://code.claude.com/docs/**供深入学习。

What You'll Learn

你将学到

TopicPro-Workflow PatternOfficial Docs
Sessions & context managementPattern 7: Context DisciplineCommon Workflows
Modes (Plan/Normal/Auto/Delegate)Pattern 5: 80/20 ReviewCommon Workflows
CLAUDE.md & project memoryPattern 4: Split MemorySettings
Writing rules & constraintsPattern 1: Self-Correction LoopSettings
Effective promptingPattern 5: 80/20 Review
Skills & automationPattern 8: Learning LogSettings
Custom subagentsPattern 2: Parallel WorktreesSub-agents
Agent teamsPattern 2: Parallel WorktreesAgent Teams
Hooks & quality gatesAll hooks in hooks.jsonHooks
Context compactionPattern 7: Context DisciplineCommon Workflows
Adaptive thinkingPattern 6: Model Selection
Security & permissionsSecurity
MCP configurationPattern 7: Context DisciplineMCP
主题专业工作流模式官方文档
会话与上下文管理模式7: 上下文管理规范通用工作流
模式(计划/常规/自动/委托)模式5: 80/20审查通用工作流
CLAUDE.md与项目记忆模式4: 拆分式记忆设置
编写规则与约束模式1: 自修正循环设置
高效提示模式5: 80/20审查
技能与自动化模式8: 学习日志设置
自定义子代理模式2: 并行工作树子代理
代理团队模式2: 并行工作树代理团队
钩子与质量门hooks.json中的所有钩子钩子
上下文压缩模式7: 上下文管理规范通用工作流
自适应思考模式6: 模型选择
安全与权限安全
MCP配置模式7: 上下文管理规范MCP

Learning Path

学习路径

  1. Start — CLI shortcuts, context management, modes
  2. Build — CLAUDE.md, writing rules, prompting, skills
  3. Scale — Custom subagents, agent teams, hooks, MCP, GitHub Actions
  4. Optimize — Pro-Workflow patterns 1-8, adaptive thinking, context compaction
  5. Reference — Official docs for deep dives on any topic
  1. 入门 — CLI快捷方式、上下文管理、模式
  2. 构建 — CLAUDE.md、编写规则、提示技巧、技能
  3. 规模化 — 自定义子代理、代理团队、钩子、MCP、GitHub Actions
  4. 优化 — 专业工作流模式1-8、自适应思考、上下文压缩
  5. 参考 — 官方文档深入学习任意主题

Use /learn

使用/learn

Run
/learn
for a topic-by-topic guide with practices and official doc links.

运行
/learn
获取按主题分类的指南,包含实践方法和官方文档链接。

Quick Setup

快速设置

Minimal

极简配置

Add to your CLAUDE.md:
markdown
undefined
添加至你的CLAUDE.md:
markdown
undefined

Pro Workflow

Pro Workflow

Self-Correction

Self-Correction

When corrected, propose rule → add to LEARNED after approval.
When corrected, propose rule → add to LEARNED after approval.

Planning

Planning

Multi-file: plan first, wait for "proceed".
Multi-file: plan first, wait for "proceed".

Quality

Quality

After edits: lint, typecheck, test.
After edits: lint, typecheck, test.

LEARNED

LEARNED

undefined
undefined

Full Setup

完整配置

bash
git clone https://github.com/rohitg00/pro-workflow.git /tmp/pw
cp -r /tmp/pw/templates/split-claude-md/* ./.claude/
cp -r /tmp/pw/commands/* ~/.claude/commands/

bash
git clone https://github.com/rohitg00/pro-workflow.git /tmp/pw
cp -r /tmp/pw/templates/split-claude-md/* ./.claude/
cp -r /tmp/pw/commands/* ~/.claude/commands/

Hooks

钩子

Pro-workflow includes automated hooks to enforce the patterns.
专业工作流包含自动化钩子以强制执行这些模式。

PreToolUse Hooks

PreToolUse钩子

TriggerAction
Edit/WriteTrack edit count, remind at 5/10 edits
git commitRemind to run quality gates
git pushRemind about /wrap-up
触发条件操作
编辑/写入跟踪编辑次数,在5/10次编辑时提醒
git commit提醒运行质量门检查
git push提醒执行/wrap-up

PostToolUse Hooks

PostToolUse钩子

TriggerAction
Code edit (.ts/.js/.py/.go)Check for console.log, TODOs, secrets
Test commandsSuggest [LEARN] from failures
触发条件操作
代码编辑(.ts/.js/.py/.go)检查是否存在console.log、TODO、敏感信息
测试命令从失败中建议添加[LEARN]规则

Session Hooks

会话钩子

HookAction
SessionStartLoad LEARNED patterns, show worktree count
StopPeriodic wrap-up/compact reminders
SessionEndCheck uncommitted changes, prompt for learnings
钩子操作
SessionStart加载已学习的模式,显示工作树数量
Stop定期提醒收尾/压缩
SessionEnd检查未提交变更,提示记录经验

Install Hooks

安装钩子

bash
undefined
bash
undefined

Copy hooks to your settings

复制钩子至你的设置

cp ~/skills/pro-workflow/hooks/hooks.json ~/.claude/settings.local.json
cp ~/skills/pro-workflow/hooks/hooks.json ~/.claude/settings.local.json

Or merge with existing settings

或与现有设置合并

undefined
undefined

Hook Philosophy

钩子设计理念

Based on Twitter thread insights:
  • Non-blocking - Hooks remind, don't block (except dangerous ops)
  • Checkpoint-based - Quality gates at intervals, not every edit
  • Learning-focused - Always prompt for pattern capture

基于Twitter线程的洞察:
  • 非阻塞 - 钩子仅提醒,不阻塞操作(危险操作除外)
  • 基于检查点 - 按间隔设置质量门,而非每次编辑都检查
  • 聚焦学习 - 始终提示捕获模式

Contexts

上下文模式

Switch modes based on what you're doing.
ContextTriggerBehavior
dev"Let's build"Code first, iterate fast
review"Review this"Read-only, security focus
research"Help me understand"Explore, summarize, plan
Use: "Switch to dev mode" or load context file.

根据当前工作切换模式。
上下文触发词行为
开发"Let's build"优先编码,快速迭代
审查"Review this"只读模式,聚焦安全
研究"Help me understand"探索、总结、规划
使用方式: "Switch to dev mode" 或加载上下文文件。

Agents

代理

Specialized subagents for focused tasks.
AgentPurposeTools
plannerBreak down complex tasksRead-only
reviewerCode review, security auditRead + test
用于专注任务的专用子代理。
代理用途工具
规划师拆分复杂任务只读
审查者代码审查、安全审计只读+测试

When to Delegate

何时委托

Use planner agent when:
  • Task touches >5 files
  • Architecture decision needed
  • Requirements unclear
Use reviewer agent when:
  • Before committing
  • PR reviews
  • Security concerns
在以下场景使用规划师代理:
  • 任务涉及>5个文件
  • 需要做架构决策
  • 需求不明确
在以下场景使用审查者代理:
  • 提交前
  • PR审查
  • 安全相关问题

Custom Subagents

自定义子代理

Create project-specific subagents in
.claude/agents/
or user-wide in
~/.claude/agents/
:
  • Define with YAML frontmatter + markdown system prompt
  • Control tools, model, permission mode, hooks, and persistent memory
  • Use
    /agents
    to create, edit, and manage interactively
  • Preload skills into subagents for domain knowledge
.claude/agents/
中创建项目专属子代理,或在
~/.claude/agents/
中创建全局子代理:
  • 使用YAML前置元数据+Markdown系统提示定义
  • 控制工具、模型、权限模式、钩子和持久化记忆
  • 使用
    /agents
    交互式创建、编辑和管理
  • 预加载技能以获取领域知识

Agent Teams (Experimental)

代理团队(实验性)

Coordinate multiple Claude Code sessions as a team:
  • Enable:
    CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  • Lead session coordinates, teammates work independently
  • Teammates message each other directly (not just report back)
  • Shared task list with dependency management
  • Display: in-process (Shift+Up/Down) or split panes (tmux/iTerm2)
  • Delegate mode (Shift+Tab): lead coordinates only, no code edits
  • Best for: parallel reviews, competing hypotheses, cross-layer changes
  • Docs: https://code.claude.com/docs/agent-teams

协调多个Claude Code会话组成团队:
  • 启用:
    CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
  • 主会话负责协调,子会话独立工作
  • 子会话可直接通信(不仅向主会话汇报)
  • 共享任务列表,支持依赖管理
  • 显示方式: 进程内(Shift+Up/Down)或分屏(tmux/iTerm2)
  • 委托模式(Shift+Tab): 主会话仅协调,不编辑代码
  • 最佳适用场景: 并行审查、竞争假设验证、跨层变更
  • 文档: https://code.claude.com/docs/agent-teams

MCP Config

MCP配置

Keep <10 MCPs enabled, <80 tools total.
Essential:
  • github
    - PRs, issues
  • memory
    - Persist learnings
  • filesystem
    - File ops
See
mcp-config.example.json
for setup.

保持启用的MCP数量<10,工具总数<80。
必备MCP:
  • github
    - PR、议题
  • memory
    - 持久化经验
  • filesystem
    - 文件操作
查看
mcp-config.example.json
获取设置示例。

Commands

命令

CommandPurpose
/wrap-up
End-of-session ritual
/learn-rule
Extract correction to memory
/parallel
Worktree setup guide
/learn
Claude Code best practices & save learnings
/search
Search learnings by keyword
/list
List all stored learnings
/commit
Smart commit with quality gates and code review
/insights
Session analytics, learning patterns, correction trends

命令用途
/wrap-up
会话收尾流程
/learn-rule
将修正提取至记忆
/parallel
工作树设置指南
/learn
Claude Code最佳实践&保存经验
/search
按关键词搜索经验
/list
列出所有存储的经验
/commit
包含质量门和代码审查的智能提交
/insights
会话分析、学习模式、修正趋势

Philosophy

设计理念

  1. Compound improvements - Small corrections → big gains
  2. Trust but verify - Let AI work, review at checkpoints
  3. Zero dead time - Parallel sessions
  4. Memory is precious - Yours and Claude's

From Claude Code power users and real production use.
  1. 复利式改进 - 小修正带来大提升
  2. 信任但验证 - 让AI工作,在检查点审查
  3. 零等待时间 - 并行会话
  4. 记忆宝贵 - 你的和Claude的记忆都需珍惜

来自Claude Code资深用户和实际生产场景。