TRANSLATE-BOOK — AGENT SKILL · A ONE-PAGE GUIDE
Translate a whole book, in parallel
An Agent Skill for Claude Code, Codex, Cursor, OpenClaw & more. It splits a PDF, DOCX or EPUB into chunks, hands them to batches of sub-agents that each start with a fresh context, checks every result against a manifest, and binds the book back together as HTML, DOCX, EPUB and PDF.
Not to scale: the real number of chunks depends on the length of the book (about 6,000 characters per chunk). Yellow marks the first batch. A batch runs up to 8 sub-agents by default (tunable with concurrency), and the next batch starts only after this one has landed.
§ 01The idea in one line
ONE CHUNK, ONE FRESH CONTEXTThe core move: every chunk is translated by a sub-agent with a fresh context window, so the run never suffers the context build-up and truncated output of pushing a whole book through one session. Consistency across chunks doesn't rely on memory. It comes from a glossary, excerpts of the neighboring chunks, and state files that let any run resume.
§ 02Six moving parts
ONE CARD, ONE SCRIPT · scripts/SKILL.md does the orchestrating; anything deterministic is left to the Python in scripts/. Each card links to a script on the main branch.
chunk0001.md, and so on. Footnotes become Pandoc footnotes, numbered continuously across the book. Markdown input (MinerU or Marker output) skips Calibre entirely, and math blocks are never cut in half.
scripts/convert.py→
02SHA-256 MANIFEST
Checks before the merge
Records the SHA-256 of every source chunk. Before merging, it confirms that sources and outputs pair up 1:1, no source changed after the split, no output is empty or blank, and not a single footnote marker went missing. source_fingerprint.json stops a new source file from reusing stale chunks.
scripts/manifest.py→
03TERM CONSISTENCY
A glossary every chunk obeys
Samples 5 chunks to build glossary.json (v2 schema with aliases, gender and confidence) and counts term frequencies across the book. Before a chunk is translated, it gets a three-column table (source | aliases | translation) as a hard constraint.
scripts/glossary.py→
04NEIGHBOR CONTEXT
A glance at the neighbors
Each sub-agent also sees read-only excerpts of about 300 characters: the end of the previous chunk and the start of the next. They are there only to resolve pronouns, gender and entities, and are never translated or copied into the output. No new state files.
scripts/chunk_context.py→
05FEEDBACK MERGE
Observations flow back
Alongside its translation, each sub-agent writes output_chunkNNNN.meta.json (schema in meta.py): new entities, alias guesses, attributes, conflicts. After every batch, merge_meta.py folds them into the glossary conservatively and leaves the judgment calls to the main agent.
scripts/meta.py · merge_meta.py→
06SELECTIVE RE-TRANSLATE
Redo only what changed
run_state.json records, per chunk, the glossary version, entities and hashes it was translated with. Change the glossary or the source, and plan picks out only the chunks that are really affected. Rerun after an interruption, and outputs that are still valid are skipped.
scripts/run_state.py→
Also in the box: merge_and_build.py (merge chunks → Pandoc HTML → DOCX / EPUB / PDF via Calibre), calibre_html_publish.py (a wrapper around Calibre's converter), two HTML templates, and figure_text.py (transcribes the text inside images into sidecar files and injects it into the chunks, so it goes through the same translation. The script is on main, but SKILL.md doesn't call it yet).
§ 03The pipeline, step by step
SKILL.md · WORKFLOW STEPSThe numbers on the left are the step numbers in SKILL.md. The main agent works its way down this ledger; the small print under each row is the script that step calls or the files it produces.
{book}_temp/ with the chunks, the manifest, the source fingerprint and config.txt. For PDFs dense with formulas and tables, convert them to Markdown with MinerU or Marker first.convert.py → chunk*.md · manifest.json · source_fingerprint.json
CONVERT
3.5
Build the glossaryOnce Step 3 has found all the source chunks, sample them for proper nouns and domain terms and count how often each appears. An existing glossary.json is never overwritten, so manual edits survive.glossary.py count-frequencies
GLOSSARY
3.7
Plan which chunks to translateSorts the chunks into “translate”, “record only” and “nothing to do”. The first group is this run's work queue.run_state.py plan
PLAN
4
Translate with parallel sub-agentsUp to 8 sub-agents per batch. Each reads one chunk with its own glossary table and neighbor excerpts, and writes a translation plus a meta file. A batch is done when its files are on disk, and only then does the next one go out.output_chunkNNNN.md · output_chunkNNNN.meta.json
TRANSLATE
4.5
Merge observations after each batchFirst record the batch's output, then merge the sub-agents' observations into the glossary. Conflict-free ones apply automatically; aliases and conflicts go to the main agent to decide.run_state.py record · merge_meta.py prepare-merge / apply-merge
MERGE META
5
Verify and retryMissing chunks get one retry. Then it checks the heading levels across the book (they become the ebook's table of contents) and front or back matter carried over from the original edition, and prints snapshots of the meta files and run state.merge_and_build.py --headings · merge_meta.py status · run_state.py status
VERIFY
6
Translate the titleReads the original title from config.txt. If the book has a published translated title, that is used as is, with no quotes or brackets around it.config.txt · original_title
TITLE
7
Merge and buildOnce validation passes, the chunks are merged into output.md; Pandoc renders HTML with a table of contents, and Calibre produces DOCX, EPUB and PDF. Intermediate files are kept by default.merge_and_build.py --title … --export-name …
BUILD
8–9
Report and spot-fixReports what was built and what failed. If a passage turns out wrong later, edit its output_chunkNNNN.md or delete it to have it re-translated, then rerun the build. No need to redo the whole book.run_state.py plan / record · merge_and_build.py
FIX
§ 04As an agent harness
SKILL.md ORCHESTRATES, SCRIPTS KEEP THE BOOKSOrchestration lives in Markdown; scripts keep the books.
{baseDir}, sub-agent instructions never name a platform-specific tool, and every frontmatter field stays on one line.
glossary.json and run_state.json. Sub-agents only read shared state and each writes its own meta file, so nothing needs a lock.
Mechanical guardrails: on every push to main and every PR, GitHub Actions runs compileall and the full unit test suite on Python 3.12. The unit tests need nothing beyond the standard library, because every third-party import is guarded. The full pipeline runs on the books in tests/baselines/ (standard-alice, for one), with output under tests/.artifacts/. Figures counted at main @ fac5755 (2026-11-23).
§ 05Where to start
GETTING STARTED · 5 PHASESebook-convert), Pandoc and Python 3. pypandoc and beautifulsoup4 are optional; MinerU or Marker is only needed for PDFs heavy on formulas and tables.
npx skills add deusyu/translate-bookCLAUDE CODE PLUGIN
/plugin marketplace add deusyu/translate-book /plugin install translate-book@translate-bookOPENCLAW
openclaw skills install @deusyu/translate-bookThe command asks which agents to install it for. To install globally for just one agent, add
-a <agent> -g, e.g. -a cursor -g. You can also git clone the repo into ~/.agents/skills/translate-book (shared by Codex, Cursor and others), or into ~/.claude/skills/translate-book for Claude Code. Pick the plugin or the skills directory, not both: with both in place, both get loaded. If a freshly installed Skill doesn't show up, restart the agent. Other install options are in the README.
/translate-book translate /path/to/book.pdf to JapaneseCODEX
$translate-book Translate /path/to/book.pdf into Chinese.OPENCLAW
translate /path/to/book.pdf to ChineseWith the Claude Code plugin, the command is
/translate-book:translate-book. All of these agents also take a request in plain language. The Skill then runs conversion, splitting, parallel translation, verification, merging and multi-format output on its own. If a run gets interrupted, start it again and it picks up where it left off.
output_chunkNNNN.md (not output.md) and rerun merge_and_build.py. --cleanup deletes the intermediate files for good, so save it for when the whole book is final.
python3 -m unittest discover -s tests -p 'test_*.py' -vThe project would rather get a detailed GitHub issue (what happened, what you expected, your environment, a minimal repro) than a pull request out of the blue. Changes have to be weighed together with the orchestration rules, the chunk / manifest contract and the release process the maintainer looks after.