Writer Agent
Transform documents and URLs into styled article series.
Quick Reference
| Reference | Purpose | Load at Step | DP | T1 | T2 | T3 |
|---|
| directory-structure.md | Output folder layout | Step 1 | ✓ | ✓ | ✓ | ✓ |
| decision-trees.md | Workflow decision guides | On confusion only | ✓ | ✓ | ✓ | ✓ |
| retry-workflow.md | Error recovery procedures | On error only | - | ✓ | ✓ | ✓ |
| large-doc-processing.md | Handling documents >50K words | Step 3 (if >20K) | - | - | ✓ | ✓ |
| article-writer-prompt.md | Subagent prompt templates | Step 4 | - | ✓ | ✓ | ✓ |
| context-extractor-prompt.md | Context extraction template | Step 3 (Tier 2) | - | - | ✓ | - |
| context-optimization.md | Context optimization anti-patterns | Step 3.1 | - | ✓ | ✓ | ✓ |
| detail-levels.md | Output detail level options | Step 2.5 | ✓ | ✓ | ✓ | ✓ |
DP = Direct Path | T1-T3 = Tier 1-3 | ✓ = Load | - = Skip
Dimension files (loaded at Step 2):
,
structures/{structure}.md
,
,
,
emotional_maps/{emotion}.md
Workflow Overview
Direct Path (<20K words OR <50K words with <=3 articles):
Main agent writes all articles directly without subagents.
Input → Convert → Style/Structure → Plan → Write(main) → Synthesize → Verify
1 1 2 3 4 5 6
Standard (Tier 1-2, 20K-100K words):
Input → Convert → Style/Structure → Analyze → Extract → Write → Synthesize → Verify
1 1 2 3 3 4 5 6
Fast Path (Tier 3, >=100K words):
Input → Convert → Style/Structure → Plan → Write(parallel) → Synthesize → Verify
1 1 2 3 4 5 6
Step 0: Resolve Skill Paths (BẮT BUỘC)
PHẢI thực hiện TRƯỚC mọi bước khác. Skill có thể được cài ở nhiều vị trí khác nhau.
Glob("**/writer-agent/scripts/wa-convert")
Bước 2: Từ kết quả, xác định 4 đường dẫn:
SCRIPTS_DIR = directory chứa wa-convert (ví dụ: /Users/x/.claude/skills/writer-agent/scripts)
SKILL_DIR = parent của SCRIPTS_DIR (ví dụ: /Users/x/.claude/skills/writer-agent)
VOICES_DIR = SKILL_DIR/voices (ví dụ: /Users/x/.claude/skills/writer-agent/voices)
STRUCTURES_DIR = SKILL_DIR/structures (ví dụ: /Users/x/.claude/skills/writer-agent/structures)
IDENTITIES_DIR = SKILL_DIR/identities (ví dụ: /Users/x/.claude/skills/writer-agent/identities)
AUDIENCES_DIR = SKILL_DIR/audiences (ví dụ: /Users/x/.claude/skills/writer-agent/audiences)
EMOTIONS_DIR = SKILL_DIR/emotional_maps (ví dụ: /Users/x/.claude/skills/writer-agent/emotional_maps)
Bước 3: Ghi nhớ các đường dẫn này. Tất cả commands trong các bước sau PHẢI dùng đường dẫn đã resolve, KHÔNG dùng relative path.
Ví dụ: Nếu Glob trả về
/Users/x/.claude/skills/writer-agent/scripts/wa-convert
:
- Gọi convert:
/Users/x/.claude/skills/writer-agent/scripts/wa-convert file.pdf
- Đọc voice:
/Users/x/.claude/skills/writer-agent/voices/teacher.md
- Đọc structure:
/Users/x/.claude/skills/writer-agent/structures/building-blocks.md
- Đọc identity:
/Users/x/.claude/skills/writer-agent/identities/tech-builder.md
QUAN TRỌNG: KHÔNG BAO GIỜ hardcode
.claude/skills/writer-agent/...
, luôn dùng đường dẫn tuyệt đối từ Glob.
Step 1: Input Handling
Detect input type and convert to markdown.
Output language: Luôn là tiếng Việt, bất kể source language.
| Input Type | Detection | Action |
|---|
| File (PDF/DOCX/EPUB/etc) | Path + extension | |
| URL (web page) | or | |
| YouTube URL | or | |
| Plain text / .txt / .md | No complex extension | Rewrite → |
File/URL Conversion
bash
{SCRIPTS_DIR}/wa-convert [/path/to/file.pdf or url]
Output:
docs/generated/{slug}-{timestamp}/input-handling/content.md
Plain Text Processing
- Read content (if file)
- Rewrite to structured markdown (add headings, preserve content)
- Propose title
- Execute:
bash
echo "{rewritten_content}" | {SCRIPTS_DIR}/wa-paste-text - --title "{title}"
Error Handling
| Error | Action |
|---|
| File not found | Ask for correct path |
| Unsupported format | Try Docling, confirm with user |
| URL fetch failed | Report and stop |
| Empty content | Warn, confirm before continue |
| Encrypted PDF | Ask for decrypted version |
Step 2: Select Writing Dimensions (5 Dimensions)
Hệ thống 5 chiều độc lập. User chọn từng chiều, mix-match tự do.
Flow: Voice → Structure → Identity → Audience → Emotion (tất cả bắt buộc)
Mỗi chiều có default mapping dựa trên voice. Hệ thống suggest defaults, user PHẢI confirm hoặc chọn khác cho mỗi chiều.
Skip dimension: Nếu user nói "không biết" hoặc skip → dùng default mapping → ghi nhận → tiếp tục. Không hỏi lại.
Step 2a: Select Voice
Hỏi user để confirm voice (giọng văn, tone, persona).
| Voice | File | Mô tả |
|---|
| Teacher | | "Chúng ta" đồng hành, teaching, ấm áp |
| Personal | | "Tôi" personal journey, vulnerable |
| Objective | | Neutral, data-driven, formal |
| Guide | | Đồng hành mindful, Đông-Tây |
| Investigator | | Tìm hiểu, đặt câu hỏi, challenge |
| Dialogue | | Thầy-trò đối thoại, Zen |
| Storyteller | | Kể chuyện ngôi thứ nhất, chánh niệm |
| Custom | User tạo mới | Theo templates/_voice-template.md
|
Xem
references/_dimension-comparison.md
để so sánh tất cả dimensions.
Custom voice: Nếu user muốn tạo voice riêng, copy
templates/_voice-template.md
→
, điền theo template. Tương tự cho custom structure:
structures/_structure-template.md
→
structures/{custom-name}.md
.
Step 2b: Select Structure
Hỏi user để confirm structure (tổ chức bài viết).
Mỗi voice có
trong frontmatter. Suggest default, user có thể override.
| Structure | File | Organization | Default cho |
|---|
| BLUF-Evidence | | Executive Summary → Evidence → Action | Objective |
| Building Blocks | | Hook → Intuition → Concept → Example → Apply | Teacher |
| Five Layers | | Surface → Structure → Tension → Connection → Synth | Investigator |
| Spiral Return | | Moment → Spiral deeper → Open ending | Personal |
| Master-Student | | Experience → Dialogue → Silence | Dialogue |
| Story Arc | | Scene → Encounter → Deepening → Transformation | Storyteller |
| Depth-Practice | | Present moment → Layers → Practice invitation | Guide |
Structure files:
structures/{structure}.md
Xem
references/_dimension-comparison.md
để so sánh và mix-match.
Step 2c: Select Writer Identity
Hỏi user chọn writer identity. Suggest default dựa trên voice, user confirm hoặc chọn khác.
| Identity | File | Mô tả | Default cho |
|---|
| Tech Builder | | Practitioner, pragmatic builder | Teacher |
| Contemplative Thinker | | Hành giả, tìm ý nghĩa | Personal, Guide, Dialogue, Storyteller |
| Knowledge Curator | | Cross-domain connector | Objective, Investigator |
| Custom | User tạo mới | Theo templates/_identity-template.md
| - |
Step 2d: Select Audience Profile
Hỏi user viết cho ai. Suggest default dựa trên voice, user confirm hoặc chọn khác.
| Audience | File | Mô tả | Default cho |
|---|
| Busy Professionals | | Bận, cần actionable | Objective |
| Curious Beginners | | Mới, cần clarity | Teacher, Guide |
| Deep Seekers | | Muốn chiều sâu | Personal, Investigator, Dialogue, Storyteller |
| Custom | User tạo mới | Theo templates/_audience-template.md
| - |
Step 2e: Select Emotional Map
Hỏi user muốn người đọc cảm thấy gì. Suggest default dựa trên voice, user confirm hoặc chọn khác.
| Emotion | File | Mô tả | Default cho |
|---|
| Empower & Challenge | | Growth qua discomfort | Teacher, Objective |
| Reflect & Discover | | Stillness, wonder | Personal, Guide, Dialogue, Storyteller |
| Provoke & Transform | | Challenge assumptions | Investigator |
| Custom | User tạo mới | Theo templates/_emotion-template.md
| - |
Emotion files:
emotional_maps/{emotion}.md
Flow: Chọn voice → Hệ thống suggest defaults cho tất cả → User confirm hoặc chọn khác từng cái
Default Mapping Table
📖 See:
references/_dimension-comparison.md
for full default mapping table, compatibility matrix, and mixing guidelines.
Mỗi dimension table ở trên đã ghi "Default cho" column. Dùng bảng so sánh chi tiết khi cần xác nhận compatibility.
Low Compatibility Warning: Khi user chọn combo có compatibility ★ (thấp) theo bảng ở
, thông báo user: "Combination này ít phổ biến, có thể tạo tension trong giọng văn. Bạn muốn tiếp tục hay chọn khác?". Nếu user confirm → proceed.
Conflict Resolution: Khi dimensions tạo tension (vd: Provoke & Transform + Teacher voice), Voice luôn quyết định HOW (giọng văn, tone, persona). Profile (Identity/Audience/Emotion) bổ sung WHAT (authority, đối tượng, cảm xúc). Nếu conflict: Voice wins về style/tone, Profile wins về content framing.
Step 2.5: Select Detail Level
Hỏi user để confirm output detail level.
| Level | Ratio | Description |
|---|
| Concise | 15-25% | Tóm lược, giữ ý chính |
| Standard | 30-40% | Cân bằng (Recommended) |
| Comprehensive | 50-65% | Chi tiết, giữ nhiều ví dụ |
| Faithful | 75-90% | Gần như đầy đủ, viết lại theo style |
Default: Standard (if user skips or unclear)
Calculate Target Words (Tham khảo)
LƯU Ý: Target words chỉ mang tính tham khảo. PASS/FAIL dựa trên section coverage, không phải word count.
target_ratio = midpoint of selected level
total_target = source_words × target_ratio
Per article (reference only):
article_target = (article_source_words / source_words) × total_target
# Word count để định hướng, không bắt buộc đạt chính xác
Understanding Detail Level Parameters
Two complementary concepts:
- : Controls total article length relative to source
- Standard level: 30-40% (midpoint 35%)
- This ratio applies to the entire article wordcount
- : Controls retention of examples within kept content
- Standard level: 60% of examples
- This percentage applies only to example sections
See detail-levels.md for worked examples and full specification.
Step 2.6: Tier Reference Table
Canonical tier definitions (referenced throughout documentation):
| Tier | Word Count | Strategy | Context Approach | Glossary | max_concurrent |
|---|
| Direct Path | <20K OR (<50K AND ≤3 articles) | Main agent writes all | N/A (no subagents) | Inline (~200 words) | N/A |
| Tier 1 | 20K-50K (fails Direct Path) | Subagents read source directly | No context files | Inline (~200 words) | 3 |
| Tier 2 | 50K-100K | Smart compression | Context extractors | Separate file (~600 words) | 3 |
| Tier 3 | >=100K | Fast Path, minimal overhead | No context files | Inline (~300 words) | 2 |
Priority rules:
- Direct Path conditions are checked FIRST and override tier boundaries
- Documents 20K-50K with ≤3 articles use Direct Path (not Tier 1)
- Only documents failing Direct Path conditions fall through to tier selection
Note: Direct Path
condition is further limited by language: EN ~44K, VI ~32K, mixed ~38K words. These limits are pre-computed in
structure.json → direct_path.capacity_ok
. If capacity exceeded, fallback to Tier 1.
Key differences:
- Direct Path: Main agent handles everything (no subagents)
- Tier 1: Lightweight subagents, read source via line ranges
- Tier 2: Context extraction for compression (only tier with separate glossary file)
- Tier 3: Like Tier 1 but larger chunks, more selective glossary, lower concurrency
Step 3: Analyze
Goal: Create analysis artifacts for article generation.
3.0 Processing Path Selection
Read
→ use
field (computed by
v1.2+):
structure.json → direct_path.eligible?
├─ YES AND direct_path.capacity_ok?
│ └─ DIRECT PATH
│ └─ Skip context extraction
│ └─ Main agent writes ALL articles
│ └─ ~30% faster for small documents
│
├─ YES BUT NOT direct_path.capacity_ok?
│ └─ WARN: direct_path.warning
│ └─ RECOMMEND: Use Tier 1 with subagents instead
│
├─ NO AND tier_recommendation.tier <= 2?
│ └─ STANDARD PATH (3.1-3.5)
│
└─ NO AND tier_recommendation.tier == 3?
└─ FAST PATH (Tier 3)
Note:
fields in structure.json (since v1.2) include
,
,
, and
. These are pre-computed based on word count, estimated article count, and detected language. Main agent does NOT need to recalculate these values.
Examples:
| Document | Words | Articles | Path | Reason |
|---|
| Blog post | 15K | 5 | Direct | <20K words (first condition) ✓ |
| Tutorial | 45K | 3 | Direct | <50K AND ≤3 articles (second condition) ✓ |
| Long guide | 48K | 3 | Direct → Tier 1 | Exceeds max_words for mixed (38K) ⚠️ |
| Paper | 45K | 4 | Standard | Fails both conditions (4 > 3) → use subagents |
| Book chapter | 67K | 8 | Standard | Tier 2: smart compression |
| Full book | 142K | 12 | Fast | Tier 3: reference-based |
Note: Direct Path capacity limit depends on language: EN ~44K, VI ~32K, mixed ~38K words. Use
structure.json → language
field for accurate limit.
3.1 Structure Scan
📖 READ FIRST: context-optimization.md explains anti-patterns that waste 50%+ context budget. Review before proceeding.
- ONLY read for outline, stats, tier recommendation
- DO NOT read - it wastes context budget
- Skip manual scanning (outline already in JSON)
⚠️
WARNING: Fallback mode loses 51% context optimization. Re-run
to generate
if possible.
Manual scan using efficient commands:
bash
# Extract heading structure without reading full file
grep -n "^#" docs/generated/{slug}/input-handling/content.md | head -100
# Or use line-based sampling (first 100 lines for overview)
Read(file_path, offset=1, limit=100) # Only to extract headings
⚠️
CRITICAL: Do NOT read full
during structure scan! For all tiers, subagents will read source content directly when writing articles. Reading it now wastes 90%+ context budget. See
context-optimization.md for budget examples and common mistakes.
3.1.1 Tier 3 Fast Path (>=100K words)
For very large documents, minimize analysis overhead:
| Action | Detail |
|---|
| SKIP | , context files |
| CREATE | Minimal (section-to-article mapping + line ranges) |
| EMBED | Key terms (~300 words) + dependencies inline in subagent prompts |
| SPAWN | Subagents immediately after (continuous batching) |
Context savings: ~40% reduction in main agent context.
See
large-doc-processing.md for
format, subagent prompt template, and workflow details.
3.2 Content Inventory
Use
outline directly. Section IDs, line ranges, word counts, and critical markers are all available in
.
3.3 Article Plan ()
Check user request first:
python
# Priority: User request > Auto-split
if user_specified_article_count:
# User yêu cầu số bài cụ thể (ví dụ: "chia thành 5 bài")
target_articles = user_specified_count
skip_auto_split = True
# Phân bổ sections đều cho các bài, không chia nhỏ thêm
else:
# Auto mode: chia thành 3-7 bài, mỗi bài ~10 phút đọc
target_articles = calculate_optimal_articles(total_words, detail_ratio)
skip_auto_split = False
Group sections into articles (default 3-7, or user-specified count):
markdown
| --- | ----- | ------------- | ------------- | ---------- | ------------ |
| 1 | intro | Introduction | S01, S02 | 2000 | ~13 min |
| 2 | core | Core Concepts | S03, S04, S05 | 2500 | ~13-15 min |
Rules:
- All sections must be mapped. Coverage check at end.
- Target reading time phụ thuộc detail level: Concise ~5min, Standard ~10min, Comprehensive ~13min, Faithful ~15min
- Target words/bài: 2000-3000 từ (tham khảo, không bắt buộc)
- Nếu user chỉ định số bài → tuân theo, không auto-split thêm
Content-Type Detection: Khi tạo plan, xác định
cho mỗi article (
,
,
,
,
). Embed
vào subagent prompt. Subagent ưu tiên structure file (primary), content-type hint (secondary).
Series Context (QUAN TRỌNG - tạo cùng lúc với plan):
Khi tạo
, đồng thời xác định:
markdown
## Series Context
Core message: "{1-2 câu thông điệp cốt lõi}"
| # | Title | Role | Reader Enters | Reader Exits | Bridge to Next |
| 1 | Intro | foundation | Chưa biết X | Hiểu X cơ bản | "Nhưng X trong thực tế...?" |
| 2 | Core | development | Hiểu X cơ bản | Nắm vững Y | "Y mở ra câu hỏi về Z..." |
| 3 | Adv | climax | Nắm vững Y | Kết nối Y với Z | N/A (last) |
Cách tạo Reader Enters/Exits/Bridge:
- : Kiến thức người đọc có khi bắt đầu bài (từ bài trước hoặc kiến thức nền)
- : Kiến thức người đọc đạt được sau bài (dẫn tới bài sau)
- : 1 câu gợi tò mò kết nối bài này với bài tiếp (KHÔNG dùng "Trong phần tiếp theo...")
Thông tin này sẽ được embed vào
block trong mỗi subagent prompt (xem
article-writer-prompt.md).
3.3.1 Article Splitting (Auto)
Trigger: After Step 3.3, before Step 3.4. Check each planned article.
Priority rules:
- User-specified count: Nếu user yêu cầu số bài cụ thể → tuân theo, KHÔNG auto-split
- Auto-split: Chỉ áp dụng khi user KHÔNG yêu cầu số bài cụ thể
Key constants:
- (~15 min reading time)
- (~13 min reading time)
- Atomic unit = H2 block (H2 + H3 children). NEVER split within paragraph, H3, or critical section.
When to split:
estimated_output = source_words × detail_ratio > MAX_OUTPUT_WORDS
Algorithm: Greedy grouping of H2 blocks, no minimum. See large-doc-processing.md#article-splitting-strategy for full algorithm and validation matrix.
Validate after split:
bash
{SCRIPTS_DIR}/wa-validate-split docs/generated/{book}/analysis/_plan.md
Context bridging: For Part N > 1, provide prev part topics, last paragraph, key concepts. See article-writer-prompt.md#multi-part-article-template.
3.4 Shared Context (Inline Glossary)
⚠️ TIMING: Execute AFTER Steps 3.1-3.3, BEFORE Step 3.5.
Strategy: Tier 1/3 → inline glossary (~200-300 words) embed trong prompt. Tier 2 → seed glossary → context extractors produce
. Chi tiết:
context-optimization.md#glossary-extraction-algorithm.
Article dependencies: Embed 1-2 sentences in prompt, not separate file.
3.5 Context Files
Skip for:
- Tier 1 (<50K words): Subagents read source directly via line ranges
- Tier 3 (>=100K words): Subagents read source directly via line ranges
- Direct Path (<20K words): Main agent writes directly
Decision (see decision-trees.md#3 for full tree):
- Tier 1/3 or <20K words: Skip context files (subagents read source directly via line ranges)
- Tier 2 (50K-100K): Spawn context extractor subagents (batch: min(3, article_count))
- Template:
templates/_context-file-template.md
Each context file:
analysis/XX-{slug}-context.md
3.6 Quality Gate: Analysis Complete
Before proceeding to Step 4, verify:
Step 4: Write Articles
4.0a Pre-read Voice & Structure (BẮT BUỘC)
PHẢI thực hiện TRƯỚC khi spawn subagents. Main agent đọc sẵn voice và structure files, embed nội dung vào subagent prompt. Subagent KHÔNG tự đọc các file này.
python
# Main agent đọc 1 lần, dùng cho tất cả subagents
voice_content = Read(f"{VOICES_DIR}/{voice}.md")
structure_content = Read(f"{STRUCTURES_DIR}/{structure}.md")
# Embed vào prompt thay vì truyền file path
# ĐÚNG: VOICE:\n{voice_content}
# SAI: STYLE: {VOICES_DIR}/{voice}.md (subagent phải tự đọc → lãng phí context)
Lý do: Mỗi file read trong subagent tạo ~4-6 JSON messages trong conversation transcript. Với 2 file reads (voice + structure), mỗi subagent tiết kiệm ~8-12 messages + ~300 lines content trong transcript trả về cho main agent.
4.0b Subagent Context Budget Rules
Giảm output trả về main agent:
- CONTEXT RULES - Đã embed trong prompt template, cấm subagent glob/read files thừa
- run_in_background: true - Dùng cho parallel article writing (≥3 articles). Main agent không nhận full transcript vào context, chỉ check output file khi cần.
python
# Parallel writing với run_in_background
tasks = []
for article in articles:
task = Task(
subagent_type="general-purpose",
description=f"Write: {article.title}",
run_in_background=True, # QUAN TRỌNG: tránh prompt too long
prompt=compose_prompt(article, voice_content, structure_content)
)
tasks.append(task)
# Check completion bằng Read tool trên output file
# KHÔNG dùng TaskOutput với block=true cho nhiều tasks
4.0c State Tracking (Recommended)
For resume and retry support, create/update
. Required if retry-workflow is needed (see
retry-workflow.md):
json
{
"status": "in_progress",
"current_step": 4,
"completed_articles": ["00-overview.md"],
"pending_articles": ["01-intro.md", "02-core.md"]
}
See retry-workflow.md for details.
For selective re-runs (style change or single article rewrite), see retry-workflow.md#selective-re-run.
4.1 Overview Article (Phase 1)
- Requires full series knowledge
- Template:
templates/_overview-template.md
- Target: 300-400 words (initial)
- Include placeholders for Key Takeaways and Article Index
Phase 1 content:
- Surprising insight + Micro-story + Core questions + Why It Matters
- Placeholder sections for Điểm chính and Mục lục
4.2 Content Articles
Direct Path (<20K words): Main agent writes all articles directly.
Direct Path guidelines — main agent follows cùng shared rules như subagent:
- Đọc voice file + structure file
- Đọc source content.md trực tiếp (full hoặc theo line ranges từ structure.json)
- Apply tất cả shared rules: LANGUAGE, FORMATTING, REWRITE RULE, ANTI-AI WRITING
- KHÔNG cần return format (vì không có subagent)
- Viết từng article theo , save vào
- Mỗi article MUST end with "## Các bài viết trong series"
- Coverage tracking: main agent tự tạo sau khi viết xong tất cả
Standard/Fast Path: Spawn subagents for articles 01+:
Task tool:
- subagent_type: "general-purpose"
- description: "Write: {title}"
- run_in_background: true # Dùng cho ≥3 articles
- prompt: [Use references/article-writer-prompt.md]
# QUAN TRỌNG: Dùng {voiceContent} và {structureContent} đã pre-read ở Step 4.0a
# KHÔNG truyền file paths cho subagent tự đọc
Multi-Part Articles (from Step 3.3.1):
For split articles, spawn each part sequentially within the article:
# Article 2 was split into 3 parts
1. Spawn 02-core-part1.md
2. Wait for completion → extract context bridge
3. Spawn 02-core-part2.md (with context from part1)
4. Wait → extract context bridge
5. Spawn 02-core-part3.md (with context from part2)
# Other articles can run in parallel
# e.g., 01-intro.md and 03-advanced.md can run while part2 waits
Context bridge extraction:
See
large-doc-processing.md §Context Bridge for the
function used between multi-part articles.
Prompt validation (optional, for debugging):
bash
echo "{prompt_text}" | {SCRIPTS_DIR}/wa-validate-prompt --tier {1|2|3} --stdin
Validates all required template variables are present. Exit code 0 = PASS, 1 = missing variables.
Continuous Batching (preferred over static batching):
- Tier 1-2: (smaller chunks ~3.5K words)
- Tier 3: (larger chunks ~10K words)
- Dynamic adjustment: large chunks (>8K) → reduce to 2, all small (<2K) → increase to 5
- On any completion → spawn next immediately (no batch waiting)
- Benefits: 25-35% faster than static batching
See large-doc-processing.md#continuous-batching-vs-static for full algorithm.
Progress Reporting:
After each article completes, update TaskUpdate:
- Format:
"Writing articles: {completed}/{total} completed"
- Example:
"Writing articles: 3/7 completed"
- Do NOT include time estimates
4.3 SoT Pattern (Long Articles)
When to use Skeleton-of-Thought: estimated output >2000 words AND >=5 subsections (H3 preferred, fallback to H2).
Quick decision:
→ SoT.
→ SoT.
→ SoT. Otherwise → standard write.
Workflow: Phase 1 (skeleton) → Phase 2 (expand ALL sections parallel) → Phase 3 (merge + transitions)
Benefits: 45-50% faster for long articles. See article-writer-prompt.md#sot-pattern for template.
Limitations: Priority 3 (paragraph breaks) not implemented. Ambiguous structure → default to standard write.
4.4 Coverage Tracking
Coverage Format Pipeline: Subagent returns 2-column (
) → Main agent enriches to 4-column (
Section | Assigned To | Used In | Status
) → Aggregate into
. See
§5.2 for aggregation.
IMPORTANT: PASS/FAIL chỉ dựa trên section coverage, không phải word count. Word count chỉ mang tính thống kê.
Subagent return format (see article-writer-prompt.md):
markdown
DONE: {filename} | {N} words
KEY_TAKEAWAY: Sinh lực bùng lên khi có mục đích rõ ràng và hành động mỗi ngày
COVERAGE:
|---------|--------|
| S01 | ✅ quoted |
| S02 ⭐ | ✅ faithful |
RESULT: PASS
SERIES_LIST: YES
VERIFY: "Vita Nova" (L21)
Tiêu chí PASS/FAIL:
- PASS: Tất cả assigned sections được covered HOẶC skipped với lý do hợp lệ (redundant, off-topic, user instruction)
- FAIL: Có section bị missing hoặc skipped không hợp lệ (không có lý do, hoặc "too long" / "already covered" thiếu reference)
- Word count: Chỉ thống kê, KHÔNG ảnh hưởng PASS/FAIL
Main agent enriches with "Assigned To" and "Used In" columns → aggregates into
(4-column format, see
Step 5.2).
4.5 Critical Sections
⭐ sections MUST be faithfully rewritten (không tóm tắt, không bỏ ý):
- Giữ 100% ý nghĩa và thông tin gốc, KHÔNG được tóm tắt hay lược bỏ
- PHẢI viết lại bằng tiếng Việt theo voice đã chọn
- KHÔNG copy nguyên văn từ source
- If unable to include fully → flag for review
4.6 Quality Gate: Articles Complete
Before proceeding to Step 5, verify từ subagent returns (KHÔNG cần đọc article files):
Step 5: Synthesize
5.1 Update Overview (Phase 2)
Update
with actual content for placeholder sections.
KHÔNG đọc lại articles. Dùng dữ liệu đã có:
python
# Nguồn dữ liệu cho overview (KHÔNG cần đọc article files):
key_takeaways = [] # Từ KEY_TAKEAWAY trong return format của mỗi subagent
series_list = [] # Từ _plan.md (đã có titles + descriptions từ Step 3)
core_message = "" # Từ _plan.md Series Context
Multi-part articles: Gom KEY_TAKEAWAYs của các parts thành 1 takeaway cho bài đó. Ví dụ: article 02 có 3 parts → chọn takeaway đại diện nhất hoặc tổng hợp thành 1 câu.
Điểm chính (Key Takeaways) - compose từ KEY_TAKEAWAYs:
markdown
## Điểm chính
1. **[Concept từ article 1 KEY_TAKEAWAY]**: [Expand từ takeaway]
2. **[Concept từ article 2 KEY_TAKEAWAY]**: [Expand từ takeaway]
3. **[Concept từ article 3 KEY_TAKEAWAY]**: [Expand từ takeaway]
Các bài viết trong series (Series List) - compose từ
:
markdown
## Các bài viết trong series
1. **Tổng quan - Brief description** _(đang xem)_
2. [Article 1 Title](./01-slug.md) - Brief description
3. [Article 2 Title](./02-slug.md) - Brief description
Final overview target: 400-600 words (overview đặc biệt, dùng word target thay vì section coverage)
Fallback nếu KEY_TAKEAWAY kém: Nếu takeaway quá generic hoặc trống, dùng article title + plan description từ
thay thế. KHÔNG đọc article file chỉ để cải thiện takeaway.
5.2 Coverage Aggregation
Collect subagent coverage tables → aggregate into
Process: Subagent returns 2-column (
) → Main agent enriches to 4-column (
Section | Assigned To | Used In | Status
) → Concatenate into
→ Add summary stats.
Coverage file format:
markdown
## Section Coverage Matrix
| ------- | ------------- | ------------- | ------------- |
| S01 | 01-article.md | 01-article.md | ✅ summarized |
| S02 ⭐ | 01-article.md | 01-article.md | ✅ faithful |
- Total: {N} | Used: {N} | Missing: {N}
Edge cases (reassignment, shared sections, skipped): See large-doc-processing.md#coverage-tracking.
Run validation:
bash
{SCRIPTS_DIR}/wa-validate docs/generated/{book}/analysis/_coverage.md
Step 6: Verify
6.1 Coverage Check
Soft target: Coverage nên đạt >=95% (không bắt buộc retry)
Coverage results:
├─ >= 95% → PASS (tiếp tục)
├─ 90-94% → WARNING (ghi nhận, không retry tự động)
│ └─ Chỉ retry nếu user yêu cầu
├─ < 90% → ASK USER
│ └─ Option 1: Accept as-is
│ └─ Option 2: Retry specific articles
│ └─ Option 3: Create supplementary
QUAN TRỌNG: Không tự động retry để đạt coverage target. Việc retry tốn token và thời gian, thường không cải thiện đáng kể.
6.2 Quality Checklist
Verify từ subagent returns + overview file (KHÔNG cần đọc article files):
6.3 Error Recovery (User-Driven)
Policy: Không tự động retry. Mọi lỗi đều report cho user và chờ quyết định. See retry-workflow.md.
Content Guidelines
Key rules: Source fidelity (rewrite, don't copy), ⭐ critical sections = faithful rewrite 100%, Anti-AI writing (no em dash, no AI vocabulary), NO tables/diagrams in output, MỖI article PHẢI có "## Các bài viết trong series" ở cuối. Full details: article-writer-prompt.md.
Cài đặt thư viện mới
Skill sử dụng virtual environment tại
. Khi cần cài thêm thư viện,
PHẢI activate venv trước:
bash
# 1. Activate venv (dùng SCRIPTS_DIR từ Step 0)
source {SCRIPTS_DIR}/.venv/bin/activate
# 2. Cài package
uv pip install <package>
# 3. Cập nhật requirements.txt
uv pip freeze > {SCRIPTS_DIR}/requirements.txt
KHÔNG dùng:
- khi chưa activate venv → lỗi "No virtual environment found"
uv pip install <package> --system
→ lỗi "externally managed" (Python Homebrew)
- → cần pyproject.toml, skill dùng requirements.txt
<br>