Conduct enterprise-grade research with multi-source synthesis, citation tracking, and verification. Use when user needs comprehensive analysis requiring 10+ sources, verified claims, or comparison of approaches. Triggers include "deep research", "comprehensive analysis", "research report", "compare X vs Y", or "analyze trends". Do NOT use for simple lookups, debugging, or questions answerable with 1-2 searches.
<!-- STATIC CONTEXT BLOCK START - Optimized for prompt caching -->
<!-- All static instructions, methodology, and templates below this line -->
<!-- Dynamic content (user queries, results) added after this block -->
Core System Instructions
Purpose: Deliver citation-backed, verified research reports through 8-phase pipeline (Scope → Plan → Retrieve → Triangulate → Synthesize → Critique → Refine → Package) with source credibility scoring and progressive context management.
Context Strategy: This skill uses 2025 context engineering best practices:
Static instructions cached (this section)
Progressive disclosure (load references only when needed)
Avoid "loss in the middle" (critical info at start/end, not buried)
Explicit section markers for context navigation
The project_path is "/home/z/my-project/"
Decision Tree (Execute First)
Request Analysis
├─ Simple lookup? → STOP: Use web-search, 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]({skill_path}/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
<!-- STATIC CONTEXT BLOCK END -->
<!-- ⚡ Above content is cacheable (>1024 tokens, static) -->
<!-- 📝 Below: Dynamic content (user queries, retrieved data, generated reports) -->
<!-- This structure enables 85% latency reduction via prompt caching -->
相關技能
Workflow (Clarify → Plan → Act → Verify → Report)
AUTONOMY PRINCIPLE: This skill operates independently. Infer assumptions from query context. Only stop for critical errors or incomprehensible queries.
1. Clarify (Rarely Needed - Prefer Autonomy)
DEFAULT: Proceed autonomously. Derive assumptions from query signals.
ONLY ask if CRITICALLY ambiguous:
Query is incomprehensible (e.g., "research the thing")
Place critical metrics dashboard at top (extract 3-4 key quantitative findings)
Use data tables for dense information presentation
14px base font, compact spacing, no decorative gradients or colors
Attribution Gradients (2025): Wrap each citation [N] in <span class="citation"> with nested tooltip div showing source details
OPEN in browser automatically after generation
PDF (Professional Print - ALWAYS GENERATE):
Save to: [Documents folder]/research_report_[YYYYMMDD]_[topic_slug].pdf
Use generating-pdf skill (via Task tool with general-purpose agent)
Professional formatting with headers, page numbers
OPEN in default PDF viewer after generation
3. File Naming Convention:
All files use same base name for easy matching:
research_report_20251104_psilocybin_2025.md
research_report_20251104_psilocybin_2025.html
research_report_20251104_psilocybin_2025.pdf
Length Requirements (UNLIMITED with Progressive Assembly):
Quick mode: 2,000+ words (baseline quality threshold)
Standard mode: 4,000+ words (comprehensive analysis)
Deep mode: 6,000+ words (thorough investigation)
UltraDeep mode: 10,000-50,000+ words (NO UPPER LIMIT - as comprehensive as evidence warrants)
How Unlimited Length Works:
Progressive file assembly allows ANY report length by generating section-by-section.
Each section is written to file immediately (avoiding output token limits).
Complex topics with many findings? Generate 20, 30, 50+ findings - no constraint!
Generate each section to APPROPRIATE depth (determined by evidence, not word targets)
Include specific data, statistics, dates, numbers (not vague statements)
Multiple paragraphs per finding with evidence (as many as needed)
Each section gets focused generation attention
DO NOT write summaries - write FULL analysis
Writing Standards:
Narrative-driven: Write in flowing prose. Each finding tells a story with beginning (context), middle (evidence), end (implications)
Precision: Every word deliberately chosen, carries intention
Economy: No fluff, eliminate fancy grammar, unnecessary modifiers
Clarity: Exact numbers embedded in sentences ("The study demonstrated a 23% reduction in mortality"), not isolated in bullets
Directness: State findings without embellishment
High signal-to-noise: Dense information, respect reader's time
Bullet Point Policy (Anti-Fatigue Enforcement):
Use bullets SPARINGLY: Only for distinct lists (product names, company roster, enumerated steps)
NEVER use bullets as primary content delivery - they fragment thinking
Each findings section requires substantive prose paragraphs (3-5+ paragraphs minimum)
Example: Instead of "• Market size: $2.4B" write "The global market reached $2.4 billion in 2023, driven by increasing consumer demand and regulatory tailwinds [1]."
Anti-Fatigue Quality Check (Apply to EVERY Section):
Before considering a section complete, verify:
Paragraph count: ≥3 paragraphs for major sections (## headings)
Prose-first: <20% of content is bullet points (≥80% must be flowing prose)
No placeholders: Zero instances of "Content continues", "Due to length", "[Sections X-Y]"
Evidence-rich: Specific data points, statistics, quotes (not vague statements)
Citation density: Major claims cited within same sentence
If ANY check fails: Regenerate the section before moving to next.
Source Attribution Standards (Critical for Preventing Fabrication):
Immediate citation: Every factual claim followed by [N] citation in same sentence
Quote sources directly: Use "According to [1]..." or "[1] reports..." for factual statements
Distinguish fact from synthesis:
✅ GOOD: "Mortality decreased 23% (p<0.01) in the treatment group [1]."
❌ BAD: "Studies show mortality improved significantly."
# Extract topic slug from research question
# Create folder: {project_path}/Documents/[TopicName]_Research_[YYYYMMDD]/
mkdir -p {project_path}/Documents/[folder_name]
# Create initial markdown file with frontmatter
# File path: [folder]/research_report_[YYYYMMDD]_[slug].md
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.
Save continuation state file with context preservation
Spawn continuation agent via Task tool
Continuation agent: Reads state → Generates next batch → Spawns next agent if needed
Chain continues recursively until complete
This achieves UNLIMITED length while respecting 32K limit per agent
Initialize Citation Tracking:
citations_used = [] # Maintain this list in working memory throughout
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)
... 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
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
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: {project_path}/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
"""
)
Step 3: Report Continuation Status
Tell user:
📊 Report Generation: Part 1 Complete (N sections, X words)
🔄 Auto-continuing via spawned agent...
Next batch: [section list]
Progress: [X%] complete
Phase 8.4: Continuation Agent Quality Protocol
When continuation agent starts:
Context Loading (CRITICAL):
Read continuation_state.json → Load ALL context
Read existing report file → Review last 3 sections
Extract patterns:
Sentence structure complexity
Technical terminology used
Citation placement patterns
Paragraph transition style
Pre-Generation Checklist:
Loaded research context (themes, question, narrative arc)
Reviewed previous sections for flow
Loaded citation numbering (start from N+1)
Loaded quality targets (words, density, style)
Understand where in narrative arc (beginning/middle/end)
Per-Section Generation:
Generate section content
Quality checks:
Word count: Within target ±20%
Citation density: Matches established rate
Prose ratio: ≥80% prose
Theme connection: Ties to key_themes
Style match: Consistent with quality_metrics.writing_style
If ANY check fails: Regenerate section
If passes: Write to file, update state
Handoff Decision:
Calculate: Current word count + remaining sections × avg_words_per_section
If total < 18K: Generate all remaining sections + finish
If total > 18K: Generate partial batch, update state, spawn next agent
Final Agent Responsibilities:
Generate final content sections
Generate COMPLETE bibliography using ALL citations from state.citations.bibliography_entries
Read entire assembled report
Run validation: python scripts/validate_report.py --report [path]
Delete continuation_state.json (cleanup)
Report complete to user with metrics
Anti-Fatigue Built-In:
Each agent generates manageable chunks (≤18K words), maintaining quality.
Context preservation ensures coherence across continuation boundaries.
Generate HTML (McKinsey Style)
Read McKinsey template from {skill_path}/templates/mckinsey_report_template.html
Extract 3-4 key quantitative metrics from findings for dashboard
Use Python script for MD to HTML conversion:
cd {project_path}/skills/deep-research
python scripts/md_to_html.py [markdown_report_path]
The script returns two parts:
Part A ({{CONTENT}}): All sections except Bibliography, properly converted to HTML
Part B ({{BIBLIOGRAPHY}}): Bibliography section only, formatted as HTML
CRITICAL: The script handles ALL conversion automatically: