by deusyu
An Agent Skill for Claude Code, Codex, Cursor, OpenClaw and other Agent Skills–compatible agents that translates entire books (PDF/DOCX/EPUB) into any language using parallel subagents.
# Add to your Claude Code skills
git clone https://github.com/deusyu/translate-bookGuides for using ai agents skills like translate-book.
See how translate-book compares with popular alternatives.
translate-book is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by deusyu. An Agent Skill for Claude Code, Codex, Cursor, OpenClaw and other Agent Skills–compatible agents that translates entire books (PDF/DOCX/EPUB) into any language using parallel subagents. It has 2,458 GitHub stars.
translate-book's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/deusyu/translate-book" and add it to your Claude Code skills directory (see the Installation section above). translate-book ships a SKILL.md manifest, so compatible agents can discover and load it automatically.
translate-book is primarily written in Python. It is open-source under deusyu on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh translate-book against similar tools.
No comments yet. Be the first to share your thoughts!
Available after the catalog security scan passes.
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM lists this project for discovery and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
{baseDir} below is the directory containing this SKILL.md. If your runtime does not substitute it, replace it with that absolute path before running any command.
You are a book translation assistant. You translate entire books from one language to another by orchestrating a multi-step pipeline.
Determine the following from the user's message:
zh) — e.g. zh, en, ja, ko, fr, de, es8){filename}_temp/ should be createdIf the file path is not provided, ask the user.
This skill requires a runtime that can spawn sub-agents from it (Step 4). If yours cannot, tell the user that this skill needs a runtime that can launch sub-agents, and stop. Do not fall back to translating the chunks yourself in this context, one after another or otherwise: a whole book in one context drifts and gets truncated.
Run the conversion script to produce chunks:
python3 {baseDir}/scripts/convert.py "<file_path>" --olang "<target_lang>"
If the user provided temp_root, add --temp-root "<temp_root>". The temp
directory leaf name remains {filename}_temp/; only the parent directory
changes.
The conversion needs Calibre (ebook-convert) and the pandoc binary;
pypandoc is used when installed but is not required. If convert.py stops
on a missing tool, install it and re-run the same command: the temp dir is
reused, and the book's title and author are kept in config.txt.
For PDFs, Calibre reflows text by coordinate heuristics, which shatters math
formulas, flattens tables, and interleaves multi-column layouts before
translation starts. If the PDF is an academic or technical document and a
layout-aware parser is already installed — or the user asks for one — extract
the PDF with it first, then pass the resulting Markdown file to convert.py
instead of the PDF. Markdown input (.md / .markdown) skips Calibre:
mineru-kit parse "<file_path>" -o "<name>.md"marker_single "<file_path>" --output_dir "<dir>", then use <dir>/<name>/<name>.mdKeep the PDF's file name stem for the Markdown file, because the temp
directory is named after it. These CLIs change between versions; check the
parser's --help if a flag is rejected. Do not install a parser without the
user's consent, because they download large models. Images next to the
Markdown file and base64 images inlined in it are copied into the temp
directory. --strip-page-numbers does not apply to Markdown input.
Page-number lines are detected and dropped for PDF input only; EPUB and DOCX
keep every standalone number (chapter, verse or exercise numbers). If an EPUB
prints its page numbers as text and they show up in the chunks, delete the
temp directory before translating and re-run with --detect-page-numbers.
This creates a {filename}_temp/ directory containing:
input.html (Calibre input only), input.md — intermediate fileschunk0001.md, chunk0002.md, ... — source chunks for translationmanifest.json — chunk manifest for tracking and validationsource_fingerprint.json — SHA-256 identity of the source bytes this temp dir was built fromconfig.txt — pipeline configuration with metadataIf convert.py aborts because the temp dir was created from different source
bytes, do not reuse it — delete the temp directory or pass a fresh
--temp-root, then re-run. Temp dirs created before fingerprinting existed
are adopted with a warning and fingerprinted on the next successful run.
Use Glob to find all source chunks:
Glob: {filename}_temp/chunk*.md
Exclude output_chunk*.md from the source list. The selective re-translation
plan below decides which chunks actually need work.
A separate sub-agent translates each chunk with a fresh context. Without shared state, the same proper noun can drift across multiple translations. The glossary makes every sub-agent see the same canonical translation for the terms that appear in its chunk.
If <temp_dir>/glossary.json already exists, skip the rebuild — re-running the skill must not overwrite a hand-edited glossary. To force a rebuild, delete the file.
Otherwise:
Sample chunks: read chunk0001.md, the last chunk, and 3 evenly-spaced middle chunks. If chunk_count < 5, sample all of them.
Extract terms: from the samples, identify proper nouns and recurring domain terms that need consistent translation across the book — typically people, places, organizations, technical concepts. Translate each into the target language. Skip generic vocabulary that any translator would render the same way.
Write glossary.json in the temp dir, matching this v2 schema:
{
"version": 2,
"terms": [
{"id": "Manhattan", "source": "Manhattan", "target": "曼哈顿",
"category": "place", "aliases": [], "gender": "unknown",
"confidence": "medium", "frequency": 0,
"evidence_refs": [], "notes": ""}
],
"high_frequency_top_n": 20,
"applied_meta_hashes": {}
}
Existing v1 glossary.json files are auto-upgraded to v2 on first load. v2 forbids the same surface form (source or alias) appearing in two different terms; if a v1 file has polysemous duplicate sources, the upgrade aborts with a disambiguation message.
Count frequencies by running:
python3 {baseDir}/scripts/glossary.py count-frequencies "<temp_dir>"
This scans every chunk*.md (excluding output_chunk*.md), updates each term's frequency field, and writes back atomically.
The glossary is hand-editable. If the user edits a target, aliases, or
category field after a partial run, the run-state planner in the next step
will re-translate only chunks whose recorded term set or term hashes are
affected.
Run:
python3 {baseDir}/scripts/run_state.py plan "<temp_dir>"
If the user explicitly asks to apply glossary edits to outputs produced before
run_state.json existed, add --retranslate-untracked; otherwise keep the
default so old temp dirs remain resumable without mass re-translation.
Capture stdout JSON:
translation_chunk_ids — chunks to translate in this run.record_only_chunk_ids — existing valid outputs that need run_state.json
records but do not need translation.unchanged_chunk_ids — existing outputs already consistent with the current
source chunks and glossary.If record_only_chunk_ids is non-empty, record them before launching
sub-agents:
python3 {baseDir}/scripts/run_state.py record "<temp_dir>" chunk0001 chunk0002 ...
Use translation_chunk_ids as the work queue for Step 4. If it is empty, skip
to Step 5.
Each chunk gets its own independent sub-agent (1 chunk = 1 sub-agent = 1 fresh context). This prevents context accumulation and output truncation. If you cannot spawn sub-agents, stop as described at the end of Step 1.
Launch chunks in batches to respect API rate limits:
concurrency sub-agents in parallel (default: 8)On some runtimes the spawn call returns as soon as the sub-agent starts and
the agent keeps running in the background. "Complete" means the files exist,
not that the spawn call returned: before launching the next batch, check that
every chunk in the batch has a non-empty output_chunk<NNNN>.md and its
output_chunk<NNNN>.meta.json (the meta file is written last). Poll for them
instead of assuming. Also read each spawn call's result: a refused spawn (for
example a runtime limit on concurrent sub-agents) returns an error instead of
an agent. Count it as not started, keep the chunk queued, and wait for running
agents to finish before launching more. Never launch a chunk that already
has an agent running, or two agents will write the same output file.
Spawn each sub-agent with the following task. Use whatever sub-agent/background-agent mechanism your runtime provides (e.g. the Agent or Task tool, sessions_spawn, invoke_subagent, or equivalent).
The output file is output_ prefixed to the source filename: chunk0001.md → output_chunk0001.md.
Translate the file
<temp_dir>/chunk<NNNN>.mdto {TARGET_LANGUAGE} and write the result to<temp_dir>/output_chunk<NNNN>.md. Follow the translation rules below. Output only the translated content — no commentary.
Each sub-agent receives:
Term table assembly — before spawning a sub-agent, run:
python3 {baseDir}/scripts/glossary.py print-terms-for-chunk "<temp_dir>" "chunk<NNNN>.md"
Capture stdout. The CLI emits a 3-column markdown table (原文 | 别名 | 译文) of every term that either appears in this chunk (by source OR any alias) OR is in the top-N most-frequent terms book-wide. Inject the table as {TERM_TABLE} in rule #13 of the translation prompt. If stdout is empty (no glossary, or no relevant terms), omit rule #13 from this chunk's prompt entirely — do not leave a dangling {TERM_TABLE} placeholder.
Neighbor context assembly — before spawning a sub-agent, run:
python3 {baseDir}/scripts/chunk_context.py "<temp_dir>" "chunk<NNNN>.md"
Capture stdout. The CLI emits prompt-ready read-only excerpts: the last ~300
characters of the previous chunk and the first ~300 characters of the next
chunk when those files exist. Inject this block as {NEIGHBOR_CONTEXT}. If
stdout is empty, omit the neighbor-context block entirely. The sub-agent must
not translate neighboring excerpts or copy them into the output; they are only
for pronoun, gender, and entity-resolution context.
Each sub-agent's task:
chunk0001.md)output_chunk0001.mdoutput_chunk0001.meta.json matching the schema below. Non-blocking — leave fields empty if unsure; do not invent entities. Always emit the file (even if all arrays are empty), because its presence + content hash is how the main agent tracks whether feedback was already merged.Sub-agent meta schema (output_chunk<NNNN>.meta.json):
{
"schema_version": 1,
"new_entities": [
{"source": "Taig", "target_proposal": "泰格", "category": "person",
"evidence": "<≤200-char quote from the chunk>"}
],
"alias_hypotheses": [
{"variant": "Taig", "may_be_alias_of_source": "Tai",
"evidence": "<≤200-char quote>"}
],
"attribute_hypotheses": [
{"entity_source": "Tai", "attribute": "gender", "value": "male",
"confidence": "high", "evidence": "<≤200-char quote>"}
],
"used_term_sources": ["Tai", "Manhattan"],
"conflicts": [
{"entity_source": "Tai", "field": "target", "injected": "泰",
"observed_better": "太一", "evidence": "<≤200-char quote>"}
]
}
Do NOT include a chunk_id field — chunk identity is derived from the filename. Putting it in the payload creates a hallucination hole and validation will reject the file.
The meta file is read by the main agent later and merged into glossary.json (see merge_meta.py). Sub-agents should fill the schema honestly: cite real quotes from the chunk, never invent entities to "look productive". An empty meta is a perfectly valid output.
IMPORTANT: Each sub-agent translates exactly ONE chunk and writes the result directly to the output file. No START/END markers needed.
Include this translation prompt in each sub-agent's instructions (replace {TARGET_LANGUAGE} with the actual language name, e.g. "Chinese"):
请翻译markdown文件为 {TARGET_LANGUAGE}. IMPORTANT REQUIREMENTS:
$...$、公式块 $$...$$)内的 LaTeX 原样保留,不要翻译、改写或删除其中任何字符| ... | 表格或 HTML <table>)保持行列结构不变,只翻译单元格中的文字[^12] 与行首的定义标记 [^12]: 原样保留,不要改编号、不要删除、不要移动位置,只翻译定义后面的注释文字;定义的续段保持行首四个空格的缩进::: {.figure-text image="..."} 和单独成行的结尾 ::: 原样保留(半角冒号,花括号里的内容一个字符都不要改),只逐条翻译两行之间 - 条目的文字,不要合并、拆分或删除条目;条目里的反斜杠转义(如 \*、\[)保留所有  格式的图片引用必须完整保留
图片文件名和路径不要修改(如 media/image-001.png)
图片alt文本可以翻译,但必须保留图片引用结构
不要删除、过滤或忽略任何图片相关内容
图片引用示例: -> 
原始 HTML 标签(如 <img alt="..." />、<a title="...">)必须保持合法:翻译 alt、title 等属性值内部文本时,下列字符会破坏 HTML 结构,必须替换为安全形式(仅适用于原始 HTML 标签的属性值内部;普通 Markdown 正文、代码块、URL 不要主动转义):
| 字符 | 在属性值内的危险 | 替换为 |
|---|---|---|
" |
闭合 attr="..." |
目标语言合适的弯引号(如中文 “ ”)或 " |
' |
闭合 attr='...' |
目标语言合适的弯引号(如中文 ‘ ’)或 ' |
< |
被解析为新标签 | < |
> |
被解析为标签结束 | > |
& |
被解析为实体起始(除非已是 &xxx;) |
& |
不要修改 src、href 等结构性属性的值,只翻译可见文本属性(alt、title)。
alt="爱丽丝拿着标着"喝我"的瓶子" ← 内层英文 " 把外层 alt 撑断了alt="爱丽丝拿着标着“喝我”的瓶子" 或 alt="爱丽丝拿着标着"喝我"的瓶子"{TERM_TABLE}
邻居上下文(只读,不要翻译,不要写入输出,只用于判断代词、性别、别名和跨 chunk 指代;为空则省略):
{NEIGHBOR_CONTEXT}
markdown文件正文:
Each sub-agent emitted an output_chunk<NNNN>.meta.json alongside its translated chunk. After every batch completes, first record the completed chunk outputs in run_state.json while the glossary is still the one used for that batch, then merge observations into the canonical glossary so subsequent batches see an enriched glossary.
Record successfully translated chunks from this batch before mutating the glossary:
python3 {baseDir}/scripts/run_state.py record "<temp_dir>" chunk0001 chunk0002 ...
If this fails, fix the missing/empty output or state error before continuing.
Run prepare-merge:
python3 {baseDir}/scripts/merge_meta.py prepare-merge "<temp_dir>"
Capture stdout JSON. It contains four arrays:
auto_apply — new entities with no glossary collision and unanimous (target, category) across all proposing chunks.decisions_needed — items requiring main-agent judgment. Each has id, kind, an options array, and the data needed to pick. Kinds:
alias — {variant, candidate_source, evidence}. Choices: yes_alias / no_separate_entity / skip.conflict — {entity_source, field, current, proposed, evidence}. Choices: keep_current / accept_proposed / record_in_notes.new_entity_existing_alias — sub-agents propose proposed_source as a new entity, but it's already someone's alias. {proposed_source, currently_alias_of, promoted_variants: [{target_proposal, category, evidence, evidence_chunks}, ...]}. Choices: one use_variant_N per distinct (target, category) promotion variant (promote proposed_source to standalone with that target+category, removing it from the host's aliases) / keep_as_alias / skip.existing_entity_conflict — sub-agents proposed a (target, category) for entity_source that differs from the canonical. Multiple distinct differing proposals all get exposed. {entity_source, current_target, current_category, proposed_variants: [{target_proposal, category, evidence, evidence_chunks}, ...]}. Choices: keep_current / one use_variant_N per competing proposal (overwrites both target AND category, stamps the prior values into notes) / record_in_notes (canonical unchanged; every proposed variant gets logged to notes).alias_or_new_entity — variant has multiple competing options that can't all coexist under v2's surface-form uniqueness rule. Triggered when (a) variant was proposed both as a new standalone entity AND as an alias of one or more candidates, OR (b) variant was proposed as an alias of two or more different candidates with no standalone competitor. {variant, alias_candidates: [{candidate_source, evidence, evidence_chunks}, ...], standalone_variants: [{target_proposal, category, evidence, evidence_chunks}, ...]}. Choices: one use_alias_N per candidate (attach as alias of that candidate), one use_standalone_N per competing standalone proposal (add as standalone with that target+category), or skip.conflicting_new_entity_proposals — {source, variants: [{target_proposal, category, evidence, evidence_chunks}, ...]}. Choices: use_variant_0, use_variant_1, ..., skip.consumed_chunk_ids — every meta file scanned this round (regardless of whether it produced a finding). These hashes get recorded in applied_meta_hashes on apply.malformed_meta_chunk_ids — meta files that failed validation. Quarantined: not consumed, not crashing the run. Surface them in your batch progress.If consumed_chunk_ids is empty → nothing was scanned; skip to Step 5.
If consumed_chunk_ids is non-empty but both auto_apply and decisions_needed are empty → still pipe {"auto_apply": [], "decisions": [], "consumed_chunk_ids": [...]} into apply-merge so the hashes get recorded. Skipping this is the bug — no-op metas would re-scan forever otherwise.
Otherwise, resolve each decision:
Read its evidence quotes inline.
Pick one option from its options array.
Build a decisions entry that round-trips the original decision plus your choice. The entry MUST include the original kind and (for conflicting_new_entity_proposals) the variants array, so apply-merge can validate and act:
{"id": "d1", "kind": "alias", "variant": "Taig", "candidate_source": "Tai", "choice": "yes_alias"}
Pipe the decisions JSON into apply-merge:
echo '{"auto_apply": [...], "decisions": [...], "consumed_chunk_ids": [...]}' \
| python3 {baseDir}/scripts/merge_meta.py apply-merge "<temp_dir>"
Surface the summary JSON (auto_applied, decisions_resolved, consumed_chunks, errors) in your batch progress message.
apply-merge is transactional. If any decision is malformed (wrong choice for kind, missing fields, references a non-existent entity), the entire batch aborts with a non-zero exit and stderr details — no glossary mutation, no hashes recorded. On non-zero exit, fix the offending decision and re-pipe; prepare-merge will surface the same proposals because nothing was consumed.
Decision order in the input list is not significant. apply-merge internally dispatches entity-creating decisions before alias-attaching ones, so yes_alias decisions whose candidate is created by another decision in the same batch (a use_standalone_N, use_variant_N, or promote_to_separate_entity) succeed regardless of the order you pass them in. Alias chains (e.g. Taighi → Taig where Taig → Tai is also a pending alias decision) resolve via a fixed-point loop within the alias-attacher pass — you don't need to topo-sort or sequence chained aliases manually.
On a fresh run after a previous interrupted batch, prepare-merge will pick up any meta files left behind. Don't manually delete them.
After all batches complete, use Glob to check that every source chunk has a corresponding output file.
If any are missing, retry them — each missing chunk as its own sub-agent. Maximum 2 attempts per chunk (initial + 1 retry).
Also read manifest.json and verify:
Check the heading structure of the whole book, since each chunk was translated
in isolation and headings decide the EPUB/PDF table of contents. This lists
every heading of the output chunks in book order, leaving out # lines inside
code blocks:
python3 {baseDir}/scripts/merge_and_build.py --temp-dir "<temp_dir>" --headings
Look for chapters split into two headings (a bare number heading followed by
the title heading), the same kind of unit at different levels (one chapter
#, the next ##), and back-matter sections nested under the index. Fix
them in the output_chunk*.md files and record each edited chunk (see the
Edit path in Step 9).
Also look at front and back matter carried over from the source edition, which no longer fits the translated book: a printed contents list copied from the source (the reader builds its own TOC), a "page numbers follow the print edition" accessibility note, and an index whose page numbers refer to the print edition. Tell the user what you found and remove or annotate it only with their agreement.
Then run the meta-merge observability snapshot:
python3 {baseDir}/scripts/merge_meta.py status "<temp_dir>"
Also run the selective re-translation state snapshot:
python3 {baseDir}/scripts/run_state.py status "<temp_dir>"
Surface a one-line summary in the verification report:
Translated chunks: 50 • Meta files: 48 found / 47 consumed • Malformed: 1 (chunk0099 — see stderr) • Chunks missing meta: chunk0017, chunk0042
Severity rules (none of these fail the run — meta is non-blocking):
unmerged_meta_files > 0 after Step 4.5 ran → bug, flag prominently. Resume should have caught this.malformed_meta_files > 0 → sub-agent emitted invalid meta; print chunk_ids and a "fix the file by hand and re-run if you want this chunk's feedback merged" note.meta_files_found < translated_chunks → sub-agent-compliance issue (some chunks didn't emit meta at all). Print missing chunk_ids.Report any chunks that failed translation after retry.
Read config.txt from the temp directory to get the original_title field.
If it is missing (e.g. Markdown input with neither front matter nor a leading
# title), use the source file name instead.
Translate the title to the target language. If the book has a published
translation, use its title (ask the user, or search for it) rather than a
literal translation. Pass the bare title, without 书名号 or quotes: it becomes
the EPUB/DOCX/PDF metadata title, which readers show in page headers and the
library (merge_and_build.py strips a wrapping 《》 anyway).
Run the build script with the translated title:
python3 {baseDir}/scripts/merge_and_build.py --temp-dir "<temp_dir>" --title "<translated_title>" --export-name "<export_name>"
--export-name adds copies of every output named after the book
(<export_name>.epub, ...) next to the canonical book.* files, which the
pipeline keeps using internally. Use the user's export_name if given,
otherwise the translated title with characters that are invalid in file names
removed. If the user provided epub_cover, add --cover "<epub_cover>".
The build skips outputs that already exist. To rebuild after changing the
title, author, language, or cover, first delete book.html, book_doc.html,
output.html, book.docx, book.epub, book.pdf and the export copies
from the temp dir; otherwise the old metadata stays inside the files even
though the file names change.
Keep the intermediate files. The chunks, manifest.json, and run_state.json
are what make spot fixes and selective re-translation possible after the build
(see Step 9). Add --cleanup only when the user explicitly asks to delete
intermediates, and tell them first that it permanently deletes chunk*.md,
output_chunk*.md, input.html, and input.md: after that, fixing a single
chunk means converting and translating the whole book again.
The script reads output_lang from config.txt automatically. Optional overrides: --lang, --author.
This produces in the temp directory:
output.md — merged translated markdownbook.html — web version with floating TOCbook_doc.html — ebook versionbook.docx, book.epub, book.pdf — format conversions (requires Calibre)Tell the user:
Do not run --cleanup as part of this report. Offer it only after the user
says they expect no more edits, and before running it, say what it deletes
(see Step 7). Re-running the Step 7 build command with the same flags plus
--cleanup keeps the existing outputs and then deletes the intermediates; if
any format fails, the script skips cleanup and keeps them.
If the user finds problems in a few places after the build, fix the affected
chunks rather than output.md: whenever a chunk changes, the build re-merges
output.md from the chunks and discards edits made there.
Find the chunk: search <temp_dir>/output_chunk*.md for the passage.
Either edit output_chunk<NNNN>.md directly, or have it re-translated.
Edit. record stamps the chunk as matching the current source and
glossary, so first check what the planner still expects from it:
python3 {baseDir}/scripts/run_state.py plan "<temp_dir>"
If chunk appears in chunks[] with action translate, recording
would hide that. Handle it by reason:
glossary_term_hash_changed (its detail lists the term ids) or
glossary_term_selection_changed: bring those terms in line with
glossary.py print-terms-for-chunk "<temp_dir>" "chunk<NNNN>.md" in the
same edit.manifest_source_hash_changed: the source chunk was edited after
splitting. Re-run the Step 2 convert.py command first, leaving out
page-number flags such as --strip-page-numbers: once chunks exist,
those flags abort and suggest deleting the cached files or the whole
temp dir, which would also delete the translations. Without them it
keeps the existing chunks and writes their new hashes to
manifest.json. Skip this and the merge stops with "Source changed
since splitting" even after re-translating. Plan again: the chunk is
then queued with source_hash_changed_since_record.source_hash_changed_since_record or any other reason: re-translate the
chunk instead of editing it.Then record the edited output:
python3 {baseDir}/scripts/run_state.py record "<temp_dir>" chunk<NNNN>
Re-translate. Delete output_chunk<NNNN>.md and run Steps 3.7–4.5 again. The planner
re-checks the whole book, so translation_chunk_ids can also list chunks
the user did not mention, typically ones whose glossary terms changed after
they were translated (glossary_term_selection_changed or
glossary_term_hash_changed in the plan's chunks[].reasons). Translate
only the chunks the user asked for; if the plan lists others, show the user
those chunk ids with their reasons and ask before re-translating them.
Re-run the Step 7 build command with the same flags. It re-merges because
the chunk is newer than output.md, then regenerates the HTML and the other
formats.
Project page: translate.dyu.sh/en (a one-page guide)
An Agent Skill for Claude Code, Codex, Cursor, OpenClaw and other Agent Skills–compatible agents that translates entire books (PDF/DOCX/EPUB) into any language using parallel subagents.
Inspired by claude_translater. The original project uses shell scripts as its entry point, coordinating the Claude CLI with multiple step scripts to perform chunked translation. This project restructures the workflow as an Agent Skill for Claude Code, Codex, Cursor, OpenClaw, and other compatible agents, using subagents to translate chunks in parallel, with manifest-driven integrity checks, resumable runs, and multi-format output unified into a single pipeline. As the project structure and implementation differ significantly from the original, this is an independent project rather than a fork.
Input (PDF/DOCX/EPUB)
│
▼
Calibre ebook-convert → HTMLZ → HTML → Markdown
(or Markdown input, e.g. from MinerU / Marker, skipping Calibre)
│
▼
Split into chunks (chunk0001.md, chunk0002.md, ...)
│ manifest.json tracks chunk hashes
▼
Parallel subagents (8 concurrent by default)
│ each subagent: read 1 chunk → translate → write output_chunk*.md
│ batched to respect API rate limits
▼
Validate (manifest hash check, 1:1 source↔output match)
│
▼
Merge → Pandoc → HTML (with TOC) → Calibre → DOCX / EPUB / PDF
Each chunk gets its own independent subagent with a fresh context window. This prevents context accumulation and output truncation that happen when translating a full book in a single session.
run_state.json tracking glossary-sensitive re-translationebook-convert command must be available (download)pypandoc — optional (pip install pypandoc); without it the pandoc binary is called directlybeautifulsoup4 — optional, for better TOC generation (pip install beautifulsoup4)npx skills add deusyu/translate-book
The command asks which agents to install the skill for. To install it globally for one agent, pass -a <agent> -g, for example npx skills add deusyu/translate-book -a cursor -g:
-a |
Installed to |
|---|---|
claude-code |
~/.claude/skills/translate-book |
codex, cursor, gemini-cli, opencode, github-copilot |
~/.agents/skills/translate-book (shared) |
antigravity |
~/.gemini/config/skills/translate-book |
openclaw |
~/.openclaw/skills/translate-book |
Or install it manually:
mkdir -p ~/.agents/skills
git clone https://github.com/deusyu/translate-book.git ~/.agents/skills/translate-book
Codex, Cursor, Gemini CLI, OpenCode, and GitHub Copilot read ~/.agents/skills/. For Claude Code, clone into ~/.claude/skills/translate-book instead. Restart the agent if the newly installed skill does not appear.
In Claude Code:
/plugin marketplace add deusyu/translate-book
/plugin install translate-book@translate-book
In GitHub Copilot CLI:
copilot plugin marketplace add deusyu/translate-book
copilot plugin install translate-book@translate-book
Install the skill either as a plugin or into a skills directory, not both: an agent that finds both copies loads both. In Claude Code, the plugin's skill is invoked as /translate-book:translate-book.
openclaw skills install @deusyu/translate-book
In the Codex CLI or IDE extension, enter:
$translate-book Translate /path/to/book.pdf into Chinese.
Codex can also select the skill automatically when your request matches its description.
Ask the agent:
translate /path/to/book.pdf to Chinese
In Claude Code and Cursor, you can also use the slash command:
/translate-book translate /path/to/book.pdf to Japanese
In OpenCode, mention @translate-book in the request.
The skill handles the full pipeline automatically — convert, chunk, translate in parallel, validate, merge, and build all output formats.
All files are in {book_name}_temp/:
| File | Description |
|---|---|
output.md |
Merged translated Markdown |
book.html |
Web version with floating TOC |
book.docx |
Word document |
book.epub |
E-book |
book.pdf |
Print-ready PDF |
The skill needs an agent that can launch sub-agents from a skill, one per chunk. If the agent cannot, the skill says so and stops instead of translating the whole book in a single context.
| Agent | Status | Invoke |
|---|---|---|
| Cursor | Verified | /translate-book, or describe the task |
| Claude Code | Original host; minimal test not yet re-run | /translate-book (plugin install: /translate-book:translate-book), or describe the task |
| Codex | Verified | $translate-book, or describe the task |
| OpenClaw | Original host; minimal test not yet re-run | Describe the task |
| Antigravity | Installable, not yet verified | Describe the task |
| Gemini CLI | Installable, not yet verified | Describe the task |
| OpenCode | Installable, not yet verified | @translate-book, or describe the task |
| GitHub Copilot | Installable, not yet verified | Describe the task |
"Verified" means the agent passed this minimal test. Install the skill, then convert a baseline book that ships with it:
S=~/.agents/skills/translate-book # the skill's install directory
mkdir -p /tmp/tb-smoke && cd /tmp/tb-smoke
python3 "$S/scripts/convert.py" "$S/tests/baselines/diligent-dick/diligent-dick.epub" --olang zh
Then ask the agent:
Use the translate-book skill. Do not convert again; the temp directory is /tmp/tb-smoke/diligent-dick_temp. Only handle chunk0045 and chunk0046, concurrency=2, skip the glossary step, launch one sub-agent per chunk as in Step 4 of SKILL.md to translate them into Chinese, and stop when done.
The agent passes when all three hold:
python3 /absolute/path/scripts/chunk_context.py …, so {baseDir} was resolved to a real path.diligent-dick_temp/output_chunk0045* and output_chunk0046* overlap with the other sub-agent's run, so the chunks were translated in parallel rather than one after another by the main agent.python3 "$S/scripts/merge_meta.py" status diligent-dick_temp reports malformed_meta_files: 0.Ran it on an agent that is not marked Verified? Please open an issue with the agent, its version, and the three results.
tests/baselines/<book-id>/.tests/.artifacts/ and should not be committed.scripts/convert.py writes {book_name}_temp/ under the current working directory, run repository baseline tests from inside tests/.artifacts/ to keep generated files out of the repo root.mkdir -p tests/.artifacts
cd tests/.artifacts
python3 ../../scripts/convert.py ../baselines/standard-alice/standard-alice.epub --olang zh
# then run translation via the skill
python3 ../../scripts/merge_and_build.py --temp-dir standard-alice_temp --title "test"
Please open a detailed GitHub issue instead of starting with a pull request. This project is maintained as an AI-assisted skill pipeline, and changes need to be evaluated against the current orchestration rules, chunk/manifest contracts, baseline assets, and release flow in one maintainer-owned context.
Pull requests are not the preferred contribution path and may be closed in favor of an issue. If you already have a patch, include the idea, key diff, failing case, or verification notes in the issue; the maintainer may rework or split the implementation before merging.
A useful issue should include:
For bugs and feature requests, please open a [GitHub is