Loading...
Loading...
Compare original and translation side by side
Request Analysis
├─ Simple lookup? → STOP: Use WebSearch, not this skill
├─ Debugging? → STOP: Use standard tools, not this skill
└─ Complex analysis needed? → CONTINUE
Mode Selection
├─ Initial exploration? → quick (3 phases, 2-5 min)
├─ Standard research? → standard (6 phases, 5-10 min) [DEFAULT]
├─ Critical decision? → deep (8 phases, 10-20 min)
└─ Comprehensive review? → ultradeep (8+ phases, 20-45 min)
Execution Loop (per phase)
├─ Load phase instructions from [methodology](./reference/methodology.md#phase-N)
├─ Execute phase tasks
├─ Spawn parallel agents if applicable
└─ Update progress
Validation Gate
├─ Run `python scripts/validate_report.py --report [path]`
├─ Pass? → Deliver
└─ Fail? → Fix (max 2 attempts) → Still fails? → Escalate请求分析
├─ 是否为简单查询? → 终止:使用WebSearch,而非本技能
├─ 是否为调试需求? → 终止:使用标准工具,而非本技能
└─ 是否需要复杂分析? → 继续执行
模式选择
├─ 初始探索? → 快速模式(3个阶段,2-5分钟)
├─ 标准研究? → 标准模式(6个阶段,5-10分钟)【默认】
├─ 关键决策支撑? → 深度模式(8个阶段,10-20分钟)
└─ 全面综述? → 超深度模式(8+阶段,20-45分钟)
执行循环(每个阶段)
├─ 从[方法论](./reference/methodology.md#phase-N)加载阶段指令
├─ 执行阶段任务
├─ 如有需要,启动并行Agent
└─ 更新进度
验证关卡
├─ 运行`python scripts/validate_report.py --report [path]`
├─ 通过? → 交付报告
└─ 未通过? → 修复(最多2次尝试)→ 仍未通过? → 升级处理[Single message with 8+ parallel tool calls]
WebSearch #1: Core topic semantic
WebSearch #2: Technical keywords
WebSearch #3: Recent 2024-2025 filtered
WebSearch #4: Academic domains
WebSearch #5: Critical analysis
WebSearch #6: Industry trends
Task agent #1: Academic paper analysis
Task agent #2: Technical documentation deep diveWebSearch #1 → wait for results → WebSearch #2 → wait → WebSearch #3...All searches + agents launched simultaneously in one message[单条消息包含8个以上并行工具调用]
WebSearch #1: 核心主题语义搜索
WebSearch #2: 技术关键词搜索
WebSearch #3: 2024-2025年最新内容筛选
WebSearch #4: 学术领域搜索
WebSearch #5: 批判性分析搜索
WebSearch #6: 行业趋势搜索
Task agent #1: 学术论文分析
Task agent #2: 技术文档深度挖掘WebSearch #1 → 等待结果 → WebSearch #2 → 等待 → WebSearch #3...在单条消息中同时启动所有搜索和Agentpython scripts/verify_citations.py --report [path]python scripts/validate_report.py --report [path]python scripts/verify_citations.py --report [path]python scripts/validate_report.py --report [path]/code/[TopicName]_Research_[YYYYMMDD]//code/Psilocybin_Research_20251104//code/React_vs_Vue_Research_20251104//code/AI_Safety_Trends_Research_20251104/[Documents folder]/research_report_[YYYYMMDD]_[topic_slug].md/code/research_output/[Documents folder]/research_report_[YYYYMMDD]_[topic_slug].html<span class="citation">[Documents folder]/research_report_[YYYYMMDD]_[topic_slug].pdfresearch_report_20251104_psilocybin_2025.mdresearch_report_20251104_psilocybin_2025.htmlresearch_report_20251104_psilocybin_2025.pdfundefined/code/[TopicName]_Research_[YYYYMMDD]//code/Psilocybin_Research_20251104//code/React_vs_Vue_Research_20251104//code/AI_Safety_Trends_20251104/[Documents folder]/research_report_[YYYYMMDD]_[topic_slug].md/code/research_output/[Documents folder]/research_report_[YYYYMMDD]_[topic_slug].html<span class="citation">[Documents folder]/research_report_[YYYYMMDD]_[topic_slug].pdfresearch_report_20251104_psilocybin_2025.mdresearch_report_20251104_psilocybin_2025.htmlresearch_report_20251104_psilocybin_2025.pdfundefined
**Phase 8.2: Progressive Section Generation**
**CRITICAL STRATEGY:** Generate and write each section individually to file using Write/Edit tools.
This allows unlimited report length while keeping each generation manageable.
**OUTPUT TOKEN LIMIT SAFEGUARD (CRITICAL - Claude Code Default: 32K):**
Claude Code default limit: 32,000 output tokens (≈24,000 words total per skill execution)
This is a HARD LIMIT and cannot be changed within the skill.
**What this means:**
- Total output (your text + all tool call content) must be <32,000 tokens
- 32,000 tokens ≈ 24,000 words max
- Leave safety margin: Target ≤20,000 words total output
**Realistic report sizes per mode:**
- Quick mode: 2,000-4,000 words ✅ (well under limit)
- Standard mode: 4,000-8,000 words ✅ (comfortably under limit)
- Deep mode: 8,000-15,000 words ✅ (achievable with care)
- UltraDeep mode: 15,000-20,000 words ⚠️ (at limit, monitor closely)
**For reports >20,000 words:**
User must run skill multiple times:
- Run 1: "Generate Part 1 (sections 1-6)" → saves to part1.md
- Run 2: "Generate Part 2 (sections 7-12)" → saves to part2.md
- User manually combines or asks Claude to merge files
**Auto-Continuation Strategy (TRUE Unlimited Length):**
When report exceeds 18,000 words in single run:
1. Generate sections 1-10 (stay under 18K words)
2. Save continuation state file with context preservation
3. Spawn continuation agent via Task tool
4. Continuation agent: Reads state → Generates next batch → Spawns next agent if needed
5. Chain continues recursively until complete
This achieves UNLIMITED length while respecting 32K limit per agent
**Initialize Citation Tracking:**
**Section Generation Loop:**
**Pattern:** Generate section content → Use Write/Edit tool with that content → Move to next section
Each Write/Edit call contains ONE section (≤2,000 words per call)
1. **Executive Summary** (200-400 words)
- Generate section content
- Tool: Write(file, content=frontmatter + Executive Summary)
- Track citations used
- Progress: "✓ Executive Summary"
2. **Introduction** (400-800 words)
- Generate section content
- Tool: Edit(file, old=last_line, new=old + Introduction section)
- Track citations used
- Progress: "✓ Introduction"
3. **Finding 1** (600-2,000 words)
- Generate complete finding
- Tool: Edit(file, append Finding 1)
- Track citations used
- Progress: "✓ Finding 1"
4. **Finding 2** (600-2,000 words)
- Generate complete finding
- Tool: Edit(file, append Finding 2)
- Track citations used
- Progress: "✓ Finding 2"
... Continue for ALL findings (each finding = one Edit tool call, ≤2,000 words)
**CRITICAL:** If you have 10 findings × 1,500 words each = 15,000 words of findings
This is OKAY because each Edit call is only 1,500 words (under 2,000 word limit per tool call)
The FILE grows to 15,000 words, but no single tool call exceeds limits
4. **Synthesis & Insights**
- Generate: Novel insights beyond source statements (as long as needed for synthesis)
- Tool: Edit (append to file)
- Track: Extract citations, append to citations_used
- Progress: "Generated Synthesis ✓"
5. **Limitations & Caveats**
- Generate: Counterevidence, gaps, uncertainties (appropriate depth)
- Tool: Edit (append to file)
- Track: Extract citations, append to citations_used
- Progress: "Generated Limitations ✓"
6. **Recommendations**
- Generate: Immediate actions, next steps, research needs (appropriate depth)
- Tool: Edit (append to file)
- Track: Extract citations, append to citations_used
- Progress: "Generated Recommendations ✓"
7. **Bibliography (CRITICAL - ALL Citations)**
- Generate: COMPLETE bibliography with EVERY citation from citations_used list
- Format: [1], [2], [3]... [N] - each citation gets full entry
- Verification: Check citations_used list - if list contains [1] through [73], generate all 73 entries
- NO ranges ([1-50]), NO placeholders ("Additional citations"), NO truncation
- Tool: Edit (append to file)
- Progress: "Generated Bibliography ✓ (N citations)"
8. **Methodology Appendix**
- Generate: Research process, verification approach (appropriate depth)
- Tool: Edit (append to file)
- Progress: "Generated Methodology ✓"
**Phase 8.3: Auto-Continuation Decision Point**
After generating sections, check word count:
**If total output ≤18,000 words:** Complete normally
- Generate Bibliography (all citations)
- Generate Methodology
- Verify complete report
- Save copy to /code/research_output/
- Done! ✓
**If total output will exceed 18,000 words:** Auto-Continuation Protocol
**Step 1: Save Continuation State**
Create file: `/code/research_output/continuation_state_[report_id].json`
```json
{
"version": "2.1.1",
"report_id": "[unique_id]",
"file_path": "[absolute_path_to_report.md]",
"mode": "[quick|standard|deep|ultradeep]",
"progress": {
"sections_completed": [list of section IDs done],
"total_planned_sections": [total count],
"word_count_so_far": [current word count],
"continuation_count": [which continuation this is, starts at 1]
},
"citations": {
"used": [1, 2, 3, ..., N],
"next_number": [N+1],
"bibliography_entries": [
"[1] Full citation entry",
"[2] Full citation entry",
...
]
},
"research_context": {
"research_question": "[original question]",
"key_themes": ["theme1", "theme2", "theme3"],
"main_findings_summary": [
"Finding 1: [100-word summary]",
"Finding 2: [100-word summary]",
...
],
"narrative_arc": "[Current position in story: beginning/middle/conclusion]"
},
"quality_metrics": {
"avg_words_per_finding": [calculated average],
"citation_density": [citations per 1000 words],
"prose_vs_bullets_ratio": [e.g., "85% prose"],
"writing_style": "technical-precise-data-driven"
},
"next_sections": [
{"id": N, "type": "finding", "title": "Finding X", "target_words": 1500},
{"id": N+1, "type": "synthesis", "title": "Synthesis", "target_words": 1000},
...
]
}Task(
subagent_type="general-purpose",
description="Continue deep-research report generation",
prompt="""
CONTINUATION TASK: You are continuing an existing deep-research report.
CRITICAL INSTRUCTIONS:
1. Read continuation state file: /code/research_output/continuation_state_[report_id].json
2. Read existing report to understand context: [file_path from state]
3. Read LAST 3 completed sections to understand flow and style
4. Load research context: themes, narrative arc, writing style from state
5. Continue citation numbering from state.citations.next_number
6. Maintain quality metrics from state (avg words, citation density, prose ratio)
CONTEXT PRESERVATION:
- Research question: [from state]
- Key themes established: [from state]
- Findings so far: [summaries from state]
- Narrative position: [from state]
- Writing style: [from state]
YOUR TASK:
Generate next batch of sections (stay under 18,000 words):
[List next_sections from state]
Use Write/Edit tools to append to existing file: [file_path]
QUALITY GATES (verify before each section):
- Words per section: Within ±20% of [avg_words_per_finding]
- Citation density: Match [citation_density] ±0.5 per 1K words
- Prose ratio: Maintain ≥80% prose (not bullets)
- Theme alignment: Section ties to key_themes
- Style consistency: Match [writing_style]
After generating sections:
- If more sections remain: Update state, spawn next continuation agent
- If final sections: Generate complete bibliography, verify report, cleanup state file
HANDOFF PROTOCOL (if spawning next agent):
1. Update continuation_state.json with new progress
2. Add new citations to state
3. Add summaries of new findings to state
4. Update quality metrics
5. Spawn next agent with same instructions
"""
)📊 Report Generation: Part 1 Complete (N sections, X words)
🔄 Auto-continuing via spawned agent...
Next batch: [section list]
Progress: [X%] complete./templates/mckinsey_report_template.htmlcd ~/.claude/skills/deep-research
python scripts/md_to_html.py [markdown_report_path]<div class="section"><h2 class="section-title"><h3 class="subsection-title"><ul><li><table><p><strong><em><span class="citation">[N]
<span class="citation-tooltip">
<div class="tooltip-title">[Source Title]</div>
<div class="tooltip-source">[Author/Publisher]</div>
<div class="tooltip-claim">
<div class="tooltip-claim-label">Supports Claim:</div>
[Extract sentence with this citation]
</div>
</span>
</span>[folder]/research_report_[YYYYMMDD]_[slug].htmlpython scripts/verify_html.py --html [html_path] --md [md_path]open [html_path][folder]/research_report_[YYYYMMDD]_[slug].pdf
**阶段8.2:渐进式章节生成**
**关键策略:** 使用Write/Edit工具逐节生成并写入文件。
这支持报告无限制长度,同时保持每次生成的内容可控。
**输出令牌限制防护(CRITICAL - Claude Code默认:32K):**
Claude Code默认限制:32000个输出令牌(≈每次技能执行最多24000词)
这是硬限制,无法在技能内修改。
**这意味着:**
- 总输出(你的文本+所有工具调用内容)必须<32000令牌
- 32000令牌≈最多24000词
- 预留安全余量:目标总输出≤20000词
**各模式的实际报告规模:**
- 快速模式:2000-4000词 ✅(远低于限制)
- 标准模式:4000-8000词 ✅(轻松低于限制)
- 深度模式:8000-15000词 ✅(谨慎操作可实现)
- 超深度模式:15000-20000词 ⚠️(接近限制,需密切监控)
**对于超过20000词的报告:**
用户需多次运行本技能:
- 运行1:“生成第1部分(章节1-6)” → 保存至part1.md
- 运行2:“生成第2部分(章节7-12)” → 保存至part2.md
- 用户可手动合并,或请求Claude合并文件
**自动续期策略(真正的无限制长度):**
当单次运行中报告将超过18000词时:
1. 生成章节1-10(控制在18000词以内)
2. 保存包含上下文保留的续期状态文件
3. 通过Task工具启动续期Agent
4. 续期Agent:读取状态→生成下一批内容→若需继续则启动下一个Agent
5. 递归链式执行直至完成
这在尊重每个Agent的32K令牌限制的同时,实现了无限制长度
**初始化引用追踪:**
**章节生成循环:**
**模式:** 生成章节内容→使用Write/Edit工具写入内容→推进到下一章节
每个Write/Edit调用仅包含一个章节(每次调用≤2000词)
1. **执行摘要**(200-400词)
- 生成章节内容
- 工具:Write(file, content=前置内容 + 执行摘要)
- 追踪使用的引用
- 进度:“✓ 执行摘要”
2. **引言**(400-800词)
- 生成章节内容
- 工具:Edit(file, old=最后一行, new=旧内容 + 引言章节)
- 追踪使用的引用
- 进度:“✓ 引言”
3. **发现1**(600-2000词)
- 生成完整发现
- 工具:Edit(file, append 发现1)
- 追踪使用的引用
- 进度:“✓ 发现1”
4. **发现2**(600-2000词)
- 生成完整发现
- 工具:Edit(file, append 发现2)
- 追踪使用的引用
- 进度:“✓ 发现2”
... 继续生成所有发现(每个发现对应一次Edit工具调用,≤2000词)
**关键:** 若有10个发现×每个1500词=15000词的发现内容
这是可行的,因为每个Edit调用仅1500词(低于每次工具调用2000词的限制)
文件会增长到15000词,但单次工具调用不会超过限制
4. **综合与洞察**
- 生成:超越来源陈述的全新洞察(按需生成足够内容)
- 工具:Edit(追加到文件)
- 追踪:提取引用,添加至citations_used
- 进度:“生成综合内容 ✓”
5. **局限性与注意事项**
- 生成:反证、空白、不确定性(按需生成合适深度)
- 工具:Edit(追加到文件)
- 追踪:提取引用,添加至citations_used
- 进度:“生成局限性内容 ✓”
6. **建议**
- 生成:即时行动、后续步骤、研究需求(按需生成合适深度)
- 工具:Edit(追加到文件)
- 追踪:提取引用,添加至citations_used
- 进度:“生成建议内容 ✓”
7. **参考文献(CRITICAL - 所有引用)**
- 生成:包含citations_used列表中所有引用的完整参考文献
- 格式:[1], [2], [3]... [N] - 每个引用对应完整条目
- 验证:检查citations_used列表 - 若列表包含[1]至[73],则生成全部73个条目
- 不使用范围表示(如[1-50]),不使用占位符(如“其他引用”),不截断
- 工具:Edit(追加到文件)
- 进度:“生成参考文献 ✓(共N个引用)”
8. **方法论附录**
- 生成:研究流程、验证方法(按需生成合适深度)
- 工具:Edit(追加到文件)
- 进度:“生成方法论 ✓”
**阶段8.3:自动续期决策点**
生成章节后,检查字数:
**若总输出≤18000词:** 正常完成
- 生成参考文献(所有引用)
- 生成方法论
- 验证完整报告
- 保存副本至/code/research_output/
- 完成! ✓
**若总输出将超过18000词:** 自动续期协议
**步骤1:保存续期状态**
创建文件:`/code/research_output/continuation_state_[report_id].json`
```json
{
"version": "2.1.1",
"report_id": "[unique_id]",
"file_path": "[report.md的绝对路径]",
"mode": "[quick|standard|deep|ultradeep]",
"progress": {
"sections_completed": [已完成的章节ID列表],
"total_planned_sections": [总章节数],
"word_count_so_far": [当前字数],
"continuation_count": [续期次数,从1开始]
},
"citations": {
"used": [1, 2, 3, ..., N],
"next_number": [N+1],
"bibliography_entries": [
"[1] 完整引用条目",
"[2] 完整引用条目",
...
]
},
"research_context": {
"research_question": "[原始问题]",
"key_themes": ["主题1", "主题2", "主题3"],
"main_findings_summary": [
"发现1:[100词摘要]",
"发现2:[100词摘要]",
...
],
"narrative_arc": "[当前叙事位置:开头/中间/结尾]"
},
"quality_metrics": {
"avg_words_per_finding": [计算出的平均值],
"citation_density": [每1000词的引用数],
"prose_vs_bullets_ratio": [例如:"85%散文"],
"writing_style": "technical-precise-data-driven"
},
"next_sections": [
{"id": N, "type": "finding", "title": "发现X", "target_words": 1500},
{"id": N+1, "type": "synthesis", "title": "综合分析", "target_words": 1000},
...
]
}Task(
subagent_type="general-purpose",
description="继续深度研究报告生成",
prompt="""
续期任务:你需要继续一份已有的深度研究报告。
关键指令:
1. 读取续期状态文件:/code/research_output/continuation_state_[report_id].json
2. 读取现有报告以了解上下文:[状态中的file_path]
3. 读取最后3个已完成章节以了解行文风格和流程
4. 加载研究上下文:状态中的主题、叙事线、写作风格
5. 从state.citations.next_number开始继续引用编号
6. 保持状态中的质量指标(平均字数、引用密度、散文占比)
上下文保留:
- 研究问题:[来自状态]
- 已确立的关键主题:[来自状态]
- 已完成的发现:[来自状态的摘要]
- 叙事位置:[来自状态]
- 写作风格:[来自状态]
你的任务:
生成下一批章节(控制在18000词以内):
[来自状态的next_sections列表]
使用Write/Edit工具追加到现有文件:[file_path]
质量关卡(每个章节生成前验证):
- 章节字数:在[avg_words_per_finding]的±20%范围内
- 引用密度:与[citation_density]匹配,误差±0.5每1000词
- 散文占比:保持≥80%散文(而非项目符号)
- 主题对齐:章节需关联关键主题
- 风格一致:匹配[writing_style]
生成章节后:
- 若还有剩余章节:更新状态,启动下一个续期Agent
- 若为最后章节:生成完整参考文献,验证报告,清理状态文件
交接协议(若启动下一个Agent):
1. 更新continuation_state.json中的新进度
2. 将新引用添加到状态中
3. 将新发现的摘要添加到状态中
4. 更新质量指标
5. 使用相同指令启动下一个Agent
"""
)📊 报告生成:第1部分完成(共N个章节,X词)
🔄 正在通过启动的Agent自动续期...
下一批:[章节列表]
进度:[X%] 完成./templates/mckinsey_report_template.htmlcd ~/.claude/skills/deep-research
python scripts/md_to_html.py [markdown_report_path]<div class="section"><h2 class="section-title"><h3 class="subsection-title"><ul><li><table><p><strong><em><span class="citation">[N]
<span class="citation-tooltip">
<div class="tooltip-title">[来源标题]</div>
<div class="tooltip-source">[作者/出版商]</div>
<div class="tooltip-claim">
<div class="tooltip-claim-label">支持结论:</div>
[包含此引用的句子]
</div>
</span>
</span>[folder]/research_report_[YYYYMMDD]_[slug].htmlpython scripts/verify_html.py --html [html_path] --md [md_path]open [html_path][folder]/research_report_[YYYYMMDD]_[slug].pdf⚠️ Issue: [Description]
📊 Context: [What was attempted]
🔍 Tried: [Resolution attempts]
💡 Options:
1. [Option 1]
2. [Option 2]
3. [Option 3]⚠️ 问题:[描述]
📊 上下文:[尝试的操作]
🔍 已尝试:[解决尝试]
💡 选项:
1. [选项1]
2. [选项2]
3. [选项3]./scripts/./scripts/