writer-agent
npx skills add https://github.com/hoangvantuan/claude-plugin --skill writer-agent
Agent 安装分布
Skill 文档
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
Tier Workflow Files (loaded at Step 2.7 after tier determination):
| Tier | File | When |
|---|---|---|
| Direct Path | tier-direct-path.md | <20K OR (<50K AND â¤3 articles) |
| Tier 1 | tier-1-workflow.md | 20K-50K (fails Direct Path) |
| Tier 2 | tier-2-workflow.md | 50K-100K |
| Tier 3 | tier-3-workflow.md | >=100K |
Dimension files (loaded at Step 2): voices/{voice}.md, structures/{structure}.md, identities/{identity}.md, audiences/{audience}.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á» nằm á» thư mục thưá»ng hoặc thư mục ẩn (dotdir).
LƯU Ã: Glob mặc Äá»nh bá» qua thư mục ẩn (bắt Äầu bằng
.). Khi skill ÄÆ°á»£c cà i qua plugin, nó nằm trong.agents/skills/â Glob vá»i**/sẽ KHÃNG tìm ÄÆ°á»£c.
Bưá»c 1: Tìm wa-convert theo thứ tá»± ưu tiên (dừng ngay khi tìm thấy):
# 1a. Glob thư mục thưá»ng (nhanh nhất)
Glob("**/writer-agent/scripts/wa-convert")
# 1b. Nếu 1a không có kết quả â tìm trong các dotdir phá» biến
Glob(".agent/**/wa-convert")
Glob(".agents/**/wa-convert")
Glob(".claude/**/wa-convert")
# 1c. Nếu 1b vẫn không có â dùng find (tìm cả dotdir)
Bash: find . -path "*/writer-agent/scripts/wa-convert" -not -path "*/.venv/*" 2>/dev/null | head -1
Bưá»c 2: Từ kết quả, xác Äá»nh các ÄÆ°á»ng dẫn:
SCRIPTS_DIR = directory chứa wa-convert (và dụ: /Users/x/.agents/skills/writer-agent/scripts)
SKILL_DIR = parent của SCRIPTS_DIR (và dụ: /Users/x/.agents/skills/writer-agent)
VOICES_DIR = SKILL_DIR/voices
STRUCTURES_DIR = SKILL_DIR/structures
IDENTITIES_DIR = SKILL_DIR/identities
AUDIENCES_DIR = SKILL_DIR/audiences
EMOTIONS_DIR = SKILL_DIR/emotional_maps
TEMPLATES_DIR = SKILL_DIR/templates
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 tìm thấy /Users/x/.agents/skills/writer-agent/scripts/wa-convert:
- Gá»i convert:
/Users/x/.agents/skills/writer-agent/scripts/wa-convert file.pdf - Äá»c voice:
/Users/x/.agents/skills/writer-agent/voices/teacher.md - Äá»c structure:
/Users/x/.agents/skills/writer-agent/structures/building-blocks.md
QUAN TRá»NG: KHÃNG BAO GIá» hardcode path cá» Äá»nh, luôn dùng ÄÆ°á»ng dẫn tuyá»t Äá»i từ Bưá»c 1.
Bưá»c 4 (Validation): Verify paths Äã resolve:
# PHẢI verify trưá»c khi tiếp tục Step 1
assert Glob(f"{SCRIPTS_DIR}/wa-convert") # Script chÃnh
assert Glob(f"{VOICES_DIR}/*.md") # Voice files
assert Glob(f"{STRUCTURES_DIR}/*.md") # Structure files
assert Glob(f"{TEMPLATES_DIR}/*.md") # Templates
# Nếu BẤT KỲ assert nà o fail â STOP, kiá»m tra lại Bưá»c 1-2
FAIL CONDITION: Nếu cả 3 cách tìm (1a, 1b, 1c) Äá»u không tìm thấy
wa-convertâ STOP workflow hoà n toà n. KHÃNG tá»± suy Äoán paths.
Step 1: Input Handling
GUARD:
SCRIPTS_DIRÄã resolve từ Step 0. Nếu chưa â STOP, quay lại Step 0.
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 | wa-convert {path} |
| URL (web page) | http:// or https:// |
wa-convert {url} |
| YouTube URL | youtube.com or youtu.be |
wa-convert {url} |
| Plain text / .txt / .md | No complex extension | Rewrite â wa-paste-text |
File/URL Conversion
{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:
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
Há» thá»ng 5 chiá»u Äá»c láºp. User chá»n preset combo hoặc Custom Äá» mix-match tá»± do.
Preset Combos (Recommended)
Show bảng sau cho user, há»i chá»n preset hoặc “Custom”:
| Preset | Voice | Structure | Identity | Audience | Emotion |
|---|---|---|---|---|---|
| Educator | Teacher | Building Blocks | Tech Builder | Curious Beginners | Empower & Challenge |
| Storyteller | Storyteller | Story Arc | Contemplative Thinker | Deep Seekers | Reflect & Discover |
| Analyst | Objective | BLUF-Evidence | Knowledge Curator | Busy Professionals | Empower & Challenge |
| Explorer | Investigator | Five Layers | Knowledge Curator | Deep Seekers | Provoke & Transform |
| Mentor | Guide | Depth-Practice | Contemplative Thinker | Curious Beginners | Reflect & Discover |
| Reflector | Personal | Spiral Return | Contemplative Thinker | Deep Seekers | Reflect & Discover |
| Zen Master | Dialogue | Master-Student | Contemplative Thinker | Deep Seekers | Reflect & Discover |
Cách dùng: Hiá»n thá» bảng trên â Há»i user gõ tên preset (e.g. “Educator”) hoặc “Custom”.
- Nếu chá»n preset: Tất cả 5 dimensions Äã set, skip Äến Step 2.5
- Nếu chá»n Custom: Chuyá»n sang Step 2a-2f bên dưá»i (chá»n từng chiá»u)
- Adaptive structure: Dùng khi content mixed/không fit structures cá» Äá»nh. Chá» available qua Custom mode hoặc user yêu cầu trá»±c tiếp.
Step 2a-2f: Custom Mode (chá»n từng chiá»u)
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. Suggest defaults, user PHẢI confirm hoặc chá»n khác.
Step 2a: Voice â Há»i user confirm voice (giá»ng vÄn, tone, persona).
| Voice | File | Mô tả |
|---|---|---|
| Teacher | teacher.md |
“Chúng ta” Äá»ng hà nh, teaching, ấm áp |
| Personal | personal.md |
“Tôi” personal journey, vulnerable |
| Objective | objective.md |
Neutral, data-driven, formal |
| Guide | guide.md |
Äá»ng hà nh mindful, Äông-Tây |
| Investigator | investigator.md |
Tìm hiá»u, Äặt câu há»i, challenge |
| Dialogue | dialogue.md |
Thầy-trò Äá»i thoại, Zen |
| Storyteller | storyteller.md |
Ká» chuyá»n ngôi thứ nhất, chánh niá»m |
| Custom | User tạo má»i | Theo templates/voice-template.md |
Voice files: voices/{voice}.md. Xem references/dimension-comparison.md Äá» so sánh.
Step 2b: Structure â Há»i user confirm structure. Má»i voice có default_structure trong frontmatter.
| Structure | File | Organization | Default cho |
|---|---|---|---|
| BLUF-Evidence | bluf-evidence.md |
Executive Summary â Evidence â Action | Objective |
| Building Blocks | building-blocks.md |
Hook â Intuition â Concept â Example â Apply | Teacher |
| Five Layers | five-layers.md |
Surface â Structure â Tension â Connection â Synth | Investigator |
| Spiral Return | spiral-return.md |
Moment â Spiral deeper â Open ending | Personal |
| Master-Student | master-student.md |
Experience â Dialogue â Silence | Dialogue |
| Story Arc | story-arc.md |
Scene â Encounter â Deepening â Transformation | Storyteller |
| Depth-Practice | depth-practice.md |
Present moment â Layers â Practice invitation | Guide |
| Adaptive | adaptive.md |
Content-driven, flexible | Mixed content |
Structure files: structures/{structure}.md
Step 2c: Identity â Há»i user chá»n writer identity.
| Identity | File | Mô tả | Default cho |
|---|---|---|---|
| Tech Builder | tech-builder.md |
Practitioner, pragmatic builder | Teacher |
| Contemplative Thinker | contemplative-thinker.md |
Hà nh giả, tìm ý nghĩa | Personal, Guide, Dialogue, Storyteller |
| Knowledge Curator | knowledge-curator.md |
Cross-domain connector | Objective, Investigator |
| Custom | User tạo má»i | Theo templates/identity-template.md |
– |
Step 2d: Audience â Há»i user viết cho ai.
| Audience | File | Mô tả | Default cho |
|---|---|---|---|
| Busy Professionals | busy-professionals.md |
Báºn, cần actionable | Objective |
| Curious Beginners | curious-beginners.md |
Má»i, cần clarity | Teacher, Guide |
| Deep Seekers | deep-seekers.md |
Muá»n chiá»u sâu | Personal, Investigator, Dialogue, Storyteller |
| Custom | User tạo má»i | Theo templates/audience-template.md |
– |
Step 2e: Emotion â Há»i user muá»n ngưá»i Äá»c cảm thấy gì.
| Emotion | File | Mô tả | Default cho |
|---|---|---|---|
| Empower & Challenge | empower-challenge.md |
Growth qua discomfort | Teacher, Objective |
| Reflect & Discover | reflect-discover.md |
Stillness, wonder | Personal, Guide, Dialogue, Storyteller |
| Provoke & Transform | provoke-transform.md |
Challenge assumptions | Investigator |
| Custom | User tạo má»i | Theo templates/emotion-template.md |
– |
Step 2f: Compatibility Check (Custom mode only)
Sau khi chá»n xong 5 dimensions, kiá»m tra compatibility:
pairs_to_check = [(identity, voice), (audience, voice), (emotion, voice)]
low_compat = [pair for pair in pairs_to_check if compatibility(pair) == "â
"]
if low_compat:
warn(f"Combo {low_compat} có compatibility thấp (â
)")
# Há»i user: tiếp tục hay chá»n khác?
Conflict Resolution: Voice quyết Äá»nh HOW (style/tone), Profile (Identity/Audience/Emotion) bá» sung WHAT (authority, Äá»i tượng, cảm xúc).
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
Understanding Detail Level Parameters
Two complementary concepts:
**target_ratio**: Controls total article length relative to source
- Standard level: 30-40% (midpoint 35%)
**example_percentage**: Controls retention of examples within kept content
- Standard level: 60% of examples
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
<50Kcondition is further limited by language: EN ~44K, VI ~32K, mixed ~38K words. These limits are pre-computed instructure.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 2.7: Load Tier Workflow (BẮT BUá»C)
Sau khi xác Äá»nh tier từ Step 2.6, Äá»c file workflow tương ứng:
tier = determine_tier(structure_json) # Từ structure.json
if tier == "direct_path":
Read(f"{SKILL_DIR}/references/tier-direct-path.md")
elif tier == 1:
Read(f"{SKILL_DIR}/references/tier-1-workflow.md")
elif tier == 2:
Read(f"{SKILL_DIR}/references/tier-2-workflow.md")
elif tier == 3:
Read(f"{SKILL_DIR}/references/tier-3-workflow.md")
Tier workflow file chứa Steps 3-4. Sau khi hoà n thà nh Step 4, load references/steps-5-6-synthesize-verify.md cho Steps 5-6.
FAIL CONDITION: Nếu không load tier workflow file â KHÃNG biết cách xá» lý Steps 3-4 cho tier Äó. STOP và load file Äúng.
Cà i Äặt thư viá»n má»i
Skill sá» dụng virtual environment tại {SCRIPTS_DIR}/.venv. Khi cần cà i thêm thư viá»n, PHẢI activate venv trưá»c:
# 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:
uv pip install <package>khi chưa activate venv â lá»i “No virtual environment found”uv pip install <package> --systemâ lá»i “externally managed” (Python Homebrew)uv add <package>â cần pyproject.toml, skill dùng requirements.txt