docx-cli: Instructions file for Claude Code

CLAUDE.md

docx-cli CLAUDE.md is an instructions file for Claude Code from kklimuk/docx-cli. It costs 10,697 tokens per session, scanned A, original, MIT.

Repository instructions for docx-cli, a command-line tool that lets AI agents read, edit, and comment on Word .docx files.

In plain words
What is it for?
Use them when changing docx-cli code, adding subsystem guidance, running commands, or checking its tests.
Why use it?
They keep changes consistent with the project's rules and prevent subtle output, file-ordering, and testing mistakes.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: reads .claude/ paths; mentions CLAUDE.md; positional $N argument.

This is kklimuk/docx-cli's own configuration. It tells Claude Code how to work on docx-cli itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything docx-cli configures →

Reuse

Borrowing it

Nothing to install: this file belongs to kklimuk/docx-cli. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/kklimuk/docx-cli/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/kklimuk/docx-cli

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for docx-cli CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/kklimuk/docx-cli/claude-md/github.svg)](https://agentmods.dev/instructions/kklimuk/docx-cli/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/kklimuk/docx-cli/claude-md"><img src="https://agentmods.dev/badge/instructions/kklimuk/docx-cli/claude-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for docx-cli CLAUDE.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/kklimuk/docx-cli/claude-md"><img src="https://agentmods.dev/badge/instructions/kklimuk/docx-cli/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 10,697 This file is loaded in full into every session.
When invoked 10,697 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.10697 $0.10697
Opus 5.5 $0.04279 $0.04279
Sonnet 5.5 $0.02139 $0.02139
Haiku 4.5 $0.01070 $0.01070

Measured yesterday against content hash 962c4fed921e, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

docx-cli CLAUDE.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

CLAUDE.md · 125 lines

How it starts

The opening of the file, as written. The whole thing — 125 lines — stays where its author put it; the contents beside it link to each section on GitHub.

docx-cli

CLI for AI agents to read, edit, and comment on .docx files. JSON-AST output, locator-based addressing, full format fidelity via in-place XML mutation.

Bun, not Node. Use Bun.file, Bun.write, Bun.env, Bun.$. Bun loads .env automatically — no dotenv.

Subsystem-specific guidance lives in nested CLAUDE.md files that load when you edit those folders. If you need to add a new CLAUDE.md to describe a new practice for a part of the system, do so.

Conventions

These conventions are NOT SUGGESTIONS. These are rules.

  • All stdout goes through respond() (JSON ack) or writeStdout() (text) from src/cli/respond.ts — never process.stdout.write. The production sinks use lazy Bun.stdout.writer() / Bun.stderr.writer() FileSinks and await each write and flush before exit. Never switch these to Bun.write(Bun.stdout, ...) or Bun.stdout.write(...): large OS-pipe writes can repeat bytes or hang after a dependency accesses process.stdout (issue #8). Stderr goes through writeStderr() for the same reason. A reader that closes early (docx read … | head) is the consumer's choice, not a command failure: the sink swallows EPIPE, drops later writes, and the command exits with its own code — never rethrow it (main's catch-all would write the error to the same dead pipe and crash with a stack trace).
  • File naming: kebab-case, named after the primary export (xml-node.ts → XmlNode).
  • Newspaper ordering. The entry point (primary export) goes at the top; its dependencies follow in the order it uses them, then their dependencies, and so on — a file reads top-to-bottom like a newspaper. Use hoisted function declarations for internal helpers so this works at runtime; arrow functions only for inline callbacks and short utilities. Types are usually not the primary exports and should go below the functions/classes that are.
  • Feature nesting When a file accumulates too many dependencies to be read well with newspaper ordering (> 300 lines), split them into a separate folder/file named after the feature they're working on. It should be a folder if it is going to represent a logical feature of dependencies. This nesting can continue indefinitely if subfeatures have subfeatures of their own.
  • JSX is for emitters only. Files that construct fresh XML can be .tsx; readers/locators/analysis stay .ts. Components are PascalCase, accept props, may return NullableXmlNode (null skipped by flatten). Attribute names with colons use the hyphen shortcut (w-val="x" → w:val="x") or JSX spread.
  • Component vs view vs lens vs free function vs transient cursor: five shapes, one decision tree.
    • A pure props → XmlNode builder is a PascalCase component — destructure its props in the signature (no props.x access), and don't take a Document (or any package state).
    • Stateful OOXML state lives in tree-owning views, embedded as fields on Document: Body, plus one view per OPC part — StylesView, NumberingView, CommentsView, NotesView, RelationshipsView, ContentTypesView, SettingsView, CorePropertiesView, MarginalsView. Each owns its part's XmlNode tree and any maps keyed to it, and exposes a fromPackage/fromXml/writeTo lifecycle (register too, for the lazily-provisioned ones). MarginalsView is the one that owns MANY parts (every word/header{N}.xml / word/footer{N}.xml) keyed by part name rather than one — so it has no single register; the Marginals lens mints each part's rel + content-type as it allocates it. Cross-view dependencies (e.g., NotesView.ensureNoteStyles(stylesView)) are passed as method arguments — no view reaches up to Document.
    • Cross-cutting lenses (Images, Hyperlinks, Equations, TrackChanges, Comments, Fonts, Marginals) are NOT fields on Document — they're stateless, constructed at the call site: new Images(document).add(source), new TrackChanges(document).accept(["tc0"]), new Marginals(document).set(sectPrs, "footer", "default", spec), await new Fonts(document).setDefault("Times New Roman"). They hold only a back-reference; the embedded views are the state they reach through. Marginals is the header/footer authoring lens — the noun pair docx headers/docx footers share it via MarginalKind the way footnotes/endnotes share Note — reaching through MarginalsView (part trees) + relationships/content-types (part registration) + settings (the even/odd toggle) + the live <w:sectPr> reference nodes (see src/core/marginals). Fonts is the one that also touches an UNMODELED part — the document font lives in BOTH word/styles.xml <w:docDefaults> (owned by StylesView) and word/theme/theme1.xml's <a:fontScheme> (not a view: read/mutated/staged through Pkg only when set-default-font runs, so unrelated saves never re-serialize the theme blob).
    • Free functions are reserved for: pure builders (the components above), the AST reader (src/core/ast/read.ts — Document's construction pass; populates the embedded views from XML and is the sole assigner of tcN ids), and emitter helpers in src/core/blocks/table/sections that thread a Document because they touch many slices in one call. If a free function's body operates on one slice of document, make it a method on that slice's view instead.
    • Transient cursors are the one stateful shape that is NEITHER a view nor a lens: a short-lived object holding position state over a SINGLE node's child list, valid only within one mutation pass (today CellInsertionCursor in src/core/table, which keeps a batch's inserts into one <w:tc> in entry order). It holds no Document, isn't embedded on one, and dies with the pass — so don't file it as a lens. It lives beside the primitives it sequences, and the CLI constructs one per target and calls it.
  • JSX.Element = XmlNode (single, not nullable). Fragment returns a #fragment sentinel unwrapped in flatten() and serialize(). Components return null to render nothing; jsx() converts that to an empty fragment. The jsx/jsxs/jsxDEV runtime exports are distinct functions, not = jsx aliases (knip flags aliased re-exports as duplicates) — don't collapse them.
  • Path aliases: @core → src/core/index.ts, @core/* → src/core/*. Use these in src/cli/*; src/core itself uses relative sibling imports. Import the body emitters from the @core/blocks and @core/table subpaths, not the @core barrel — ast/types already exports Paragraph/Table/TableCell/TableRow as types, and barrel-merging the same-named value emitters is confusing.
  • Variable names: descriptive, no single/two-letter (paragraph not p). Exception: regex-match destructuring (const [, prefix, idx] = match).
  • Inline props in the signature. When a component's props type is used only by that component, write it inline (function HeadingStyle({ styleId }: { styleId: BaselineStyleId; … })) rather than declaring a separate named Props type. Extract a named type only when it's shared.
  • knip runs strict (bun run check, no rule overrides in knip.json). An unused export is dead code — delete it (this is a CLI app, not a library; there are no external @core consumers). The one exception: an export staged for a named upcoming tier with no caller yet gets a @public JSDoc tag whose comment names the future consumer (knip honors @public) — e.g. HorizontalRule (S8) and the r/a/wp/pic image namespaces (S5). Don't silence knip by re-adding rule suppressions.
  • Style: tabs, double quotes (Biome enforced). Early returns over else-if chains.

Read the full file on GitHub · 125 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday Changed · +1 lines · +190 tokens per session 962c4fed921e
  2. 5d ago Changed · +1 lines · +45 tokens per session 92d3a5551ef1
  3. 7d ago Changed · +9 lines · +675 tokens per session c7bfa67caca5
  4. 8d ago Changed · +12 tokens per session 9b9dd77340f9
  5. 21d ago Changed · +7 lines · +195 tokens per session 38827219eaac
  6. 1mo ago Changed · +1 lines · +707 tokens per session 4ada65fd8279
  7. 1mo ago First seen · 106 lines · 8,873 tokens per session scan A 665a4ac135ea

Subscribe to this mod's changes

docx-cli CLAUDE.md is an instructions file published in the GitHub repository kklimuk/docx-cli (225 stars, last pushed yesterday), licensed MIT. It adds 10,697 tokens to every session, about $0.0428 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 9,649 tokens

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,257 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, cache eligibility and rollout and applying the notice (cutover).

microsoft/vscode · 5,262 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,680 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 4,159 tokens

vscode copilot-instructions.md

Copilot instructions for microsoft/vscode, covering vs code copilot instructions, project overview, root folders, core architecture (src/ folder) and built-in extensions (extensions/ folder).

microsoft/vscode · 2,731 tokens