К основному содержанию
скилл CX Codex

k2f — скилл для Claude Code: документы Word, PDF и IDML

Скилл для агентов: собирает вёрстку в семантическом JSON и выгружает в docx, PDF, AcroForm и IDML. Пригодится для меню, сертификатов, планеров и приглашений.

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add suzheng/k2f --skill k2f -a claude-code
Открыть на GitHub

Что делает k2f

K2F — формат для агентов: вместо координат и цветов на узлах вы описываете смысл. У каждого узла есть стабильный точечный id, role и необязательный variant, а оформление живёт только в styles/theme.json. Файл .K2F — это ZIP из двух состояний: изменяемое дерево content/root.json и неизменяемый render lock document.K2F.lock, который и рисуют все просмотрщики.

Работа идёт одним циклом: получить рабочую папку, править JSON как исходный код, копировать готовые фигуры из catalog/content/ex_*.json в корневой children и прогонять scripts/pack_verify.py. Для форм есть отдельный пример ex_form.json — пустые поля и чекбоксы берут оттуда, а не рисуют подчёркиваниями. Диапазоны для текстовых modifiers считает scripts/modifier_range.py: вручную их не подсчитывают, особенно через переводы строк.

Перед запуском поставьте CLI: pip install k2f. Скрипты init_package.py, pack_verify.py и modifier_range.py работают на стандартной библиотеке Python, а pack_verify.py ищет k2f в PATH или в переменной K2F_CLI — без установленного пакета он не найдёт бинарник. Правки в source/ не видны, пока не выполнен compile: просмотрщики показывают lock, поэтому после изменений контента или темы нужен повторный прогон и свежий tmp/preview.png. MCP подключать не обязательно, запись без него работает.

Какие задачи решает

  • собрать меню или приглашение с аккуратной вёрсткой
  • сделать заполняемую форму AcroForm с чекбоксами
  • выгрузить готовый макет в docx для правок в Word
  • отдать дизайнеру IDML для Adobe InDesign
  • проверить, что страница не осталась пустой в нижней трети

Примеры запросов агенту

  • Собери сертификат на одного человека по шаблону из галереи и выгрузи в PDF
  • Сделай планер на неделю в K2F и добавь заполняемые поля для заметок
  • Переведи этот markdown в K2F и выгрузи docx

Как установить k2f

1Через Skills CLI (Vercel)

npx skills add suzheng/k2f --skill k2f -a claude-code

2Вручную: положить файлы

~/.claude/skills/k2f/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/k2f/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о k2f

Как установить k2f в Claude?

Выполните npx skills add suzheng/k2f --skill k2f -a claude-code. Скилл встанет в ~/.claude/skills/k2f/SKILL.md. Для работы скриптов дополнительно нужен pip install k2f.

Что делает k2f?

Даёт агенту создавать, править и проверять документы в формате K2F, а затем выгружать их в Word, PDF, AcroForm PDF, PPTX и IDML. Вёрстка описывается смысловыми ролями, а не координатами.

Нужен ли MCP-сервер для k2f?

Нет. Запись документов идёт через JSON и скрипты скилла. Если MCP с шаблонами уже подключён, download_template вернёт ссылку на пакет, который всё равно скачивают на диск и распаковывают через k2f unpack.

Исходный текст

SKILL.md · Apache-2.0
---
name: k2f
description: Create, design, edit, validate, and export elegant Word (docx), editable PDF, fillable AcroForm PDF, and Adobe InDesign (IDML) documents with K2F. Use when creating aesthetic Word, fillable PDF, AcroForm, IDML, or InDesign documents with AI agents, such as menus, certificates, planners, invitations, or worksheets and much more. K2F is a mature file format designed for AI agents to design and edit elegant aesthetic documents precisely and effortlessly. It has a rich ecosystem.
---

# K2F

Create, design, edit elegant Word (docx), PDF, fillable AcroForm PDF, and Adobe InDesign (IDML) with K2F. K2F designed for agents to design and edit elegant documents precisely and effortlessly. Use with AI agents when you need aesthetic documents—menus, certificates, planners, invitations, worksheets, and more. You can start from [Gallery](https://k2f.dev/gallery) templates.

A `.K2F` is a ZIP: you edit a semantic JSON tree (meaning, not coordinates); the engine `pack` / `compile`s an immutable render lock. One reference engine → pixel-identical output everywhere.

## Choose the workflow

Read **one** reference file for the task. Do not load all workflows.

| Task | Read |
|------|------|
| Create or update a `.K2F` (CV, flyer, slide deck, poster, report, patch by node id) | [references/writing.md](references/writing.md) |
| Convert Markdown ↔ K2F | [references/converting-markdown.md](references/converting-markdown.md) |
| Export PDF from the published lock | [references/exporting-pdf.md](references/exporting-pdf.md) — bytes / looks wrong: [pdf-contract.md](references/exporting-pdf/pdf-contract.md) |
| Export PPTX from the published lock | [references/exporting-pptx.md](references/exporting-pptx.md) |
| Export DOCX from the published lock | [references/exporting-docx.md](references/exporting-docx.md) |
| Export IDML from the published lock | [references/exporting-idml.md](references/exporting-idml.md) |
| Publish permanent `/v/{appearance_hash}` link | [references/publishing.md](references/publishing.md) |
| Embed `<k2f-viewer>` in a web app | [references/embedding-viewer.md](references/embedding-viewer.md) (`npm i @openk2f/k2f`) |

**Writing** (default): one loop — get a workspace (`source/` author package + deliverables at the root), edit JSON like source code, copy shapes from [`catalog/content/ex_*.json`](catalog/content/) into root `children` (do not replace `content/root.json` with a fragment), and `scripts/pack_verify.py`. The author directory is `k2f unpack … -o ./out/doc/source` (user `.K2F` or a Gallery package), or [`starter/`](starter/) via `scripts/init_package.py --workspace ./out/doc` when nothing matches.

- Do **not** use `Editor.insert_node` on an unpacked author directory — that API follows a narrower agent dialect; JSON authoring uses the full format schema validated at pack time.
- Text `modifiers` need `intent` plus UTF-8 **byte** `range` — always run [`scripts/modifier_range.py`](scripts/modifier_range.py); never hand-count (especially across `\n`).
- Fillable blanks/checkboxes: copy [`catalog/content/ex_form.json`](catalog/content/ex_form.json) (never `____` or `□`).

Gallery URL (`<origin>/gallery/<slug>`) or package URL: fetch `<origin>/api/gallery/templates/<slug>` (or package URL) to a `.K2F` on disk and `k2f unpack` — do not load the ZIP into context. **MCP** is optional. Writing does not require it and does not install it. If a site MCP with `list_templates` / `download_template` is already connected, `download_template` returns the same kind of `packageUrl`; fetch + unpack as in step 2 of [writing.md](references/writing.md). Missing tools, kind mismatch, or download failure → continue from `starter/`; do not stop the task.

## What K2F is

PDF is unreadable and uneditable for AI. HTML/CSS renders differently on every device. K2F fixes both: agents write plain JSON *meaning*, and one reference engine turns that meaning into pixel-identical output everywhere.

Instead of positioning content with coordinates:

    {"text": "WARNING!", "x": 100, "y": 50, "color": "red", "bold": true}

K2F authors describe meaning:

    {"id": "doc.warning", "role": "warning", "content": {"type": "text", "value": "WARNING!"}}

Every `.K2F` file is a ZIP holding two states:

- **State A — semantic tree** (`content/root.json`, mutable, the file you edit). Every node has a stable dotted `id`, a `role`, an optional `variant`, and optional `modifiers` (inline emphasis/link/math on a byte range). No coordinates, no colors, no font sizes — those live only in `styles/theme.json`, keyed by role/variant.
- **State C — render lock** (`document.K2F.lock`, immutable, generated). Exact geometry, paint operations, and integrity hashes. Every viewer and every PDF export paints *this*, not the tree.

The engine — not the agent — turns A into C by running `pack` / `compile`. Other package paths: `manifest.json` (page size, margins), `assets/fonts|images|data/*`, `changelog.json` (edit history), optional `signatures/v1.json`.

When handing a `.K2F` to the user, point them to [k2f.dev/playground](https://k2f.dev/playground) (browser) or [k2f.dev/download](https://k2f.dev/download) (desktop app).

## Setup

You have **this skill folder only** — no K2F source checkout, no `templates/` tree.

Install published tools before running workflows:

```bash
pip install k2f              # CLI on PATH + Python SDK — no need to install Cargo
npm i @openk2f/k2f           # only when embedding <k2f-viewer> in a web app
# cargo install k2f          # optional: CLI without Python
```

Run scripts from this skill directory (or pass absolute paths to them). Core scripts (`init_package.py`, `pack_verify.py`, `modifier_range.py`) are **stdlib-only** — `python scripts/…`. Optional `compare_images.py` needs `uv run` ([visual check](references/writing.md#reference-image-overlay-optional)). The author directory may live anywhere. `pack_verify.py` needs `k2f` on PATH (`pip install k2f`) or `K2F_CLI` — it does not walk a git checkout or build directory for a binary.

## Core rules

Empty paper in the **lower third** of a designed sheet is the most common visual failure. `pack_verify.py` exit 0 / `pages=1` does **not** mean filled — open the PNG. Fix: copy [`ex_filled_page.json`](catalog/content/ex_filled_page.json) as a **root child** (`height` = content box; leftover on `{fr:1}` table/notes/figure). Short letter and the last page of a growing document may stay short.

**`source/` edits are invisible until compile.** Viewers paint `document.K2F.lock`, not author JSON. After content/theme edits, run `pack_verify.py`, then `tmp/preview.png` or reload the `.K2F`. 

1. **Style lives only in `theme.json`, never on a node.** Putting a style field on a node is the single most common compile failure.
2. **Never hand-edit `document.K2F.lock`.** Mutate the tree (or theme), then `pack_verify.py` (relock).
3. **PDF, PPTX, DOCX, and IDML are one-way drawings of the lock, not a second source.** (`PDF_IS_NOT_A_SOURCE`, `PPTX_IS_NOT_A_SOURCE`, `DOCX_IS_NOT_A_SOURCE`, `IDML_IS_NOT_A_SOURCE`)
4. **Signing is a separate human/org step.** Agent output is `UNSIGNED` by design.
5. **Validate after every edit.** Fix from error codes in [writing/errors.md](references/writing/errors.md); do not patch the lock.
6. **Look at the pixels — empty bottom first.** After pack, open every rendered page (`--render` writes `preview-1.png` …). If the lower third is blank paper on a designed sheet, you are not done. **Designed sheet** (invoice, CV, flyer, poster, slide, card, social, one-page infographic/checklist/planner — even if titled report) → copy [`ex_filled_page.json`](catalog/content/ex_filled_page.json) as a **root child** (pinned `height` + `{fr:1}` grower); a `page_shell` role on a hug stack is not the shell. Treat `PAGE_UNDERFILL` as must-fix even when `pack_verify.py` exits 0 (skipped if the content box is shorter than 180pt). Short letter may stay top-packed. **Growing document** (contract, long report, thesis, paper) → one flow tree; last page may be short; no `p1`/`p2` page wrappers and no page-height shell around the whole doc. `break_before: page` is fine on a chapter, annex, signature page, slide 2+, or card back. Details: [writing.md](references/writing.md#visual-check).

## Content and design

Before editing `content/` or `styles/theme.json`, write content and design as Markdown **inside** the author directory. Long content does not go in one file. Split the same way as `content/*.json`. Name each file with a **slug**: lowercase ASCII `kebab-case` from that page or section’s topic (e.g. `executive-summary`, `title-slide`). A short single page may be one `content_and_design.md`. One page per file → `content_and_design_<slug>.md` (e.g. `content_and_design_agenda.md` for a slide). Section aligned with a JSON fragment → `content_and_design_<slug>.md` beside `content/<slug>.json` using the **same** slug. Then `python scripts/init_package.py --workspace ./out/doc …` (creates `source/` + `tmp/`; a notes-only `source/` that already holds these files can still be initialized in place).

Workspace layout:

```
./out/doc/
  doc.K2F                 # deliverable
  doc.pdf                 # optional exports, same stem
  source/                 # author package (edit this)
    content_and_design_executive-summary.md
    manifest.json
    content/
      root.json
      executive-summary.json   # optional fragment; same slug as its .md
    styles/ assets/ changelog.json
  tmp/                    # preview.png and other debug renders
```

Each file covers that page or section only, and includes both:

- **Content** — every word, and every image (what it shows, width×height; a full generation prompt when the image must be made). Need figures → [generate them](references/writing.md#figures)
- **Design** — type hierarchy, spacing, color, and layout

Shared type, color, and spacing for the whole document go in the first file. Later files state their own words and images, which shared set they use, and anything that differs.

- **User gave constraints** — follow them.
- **User did not specify** — highest aesthetic standard for the deliverable type (report, poster, slide deck, flyer, …). Do not ship the starter theme unchanged for styled work.

After the files are settled: look up allowed keys in [writing/fields.md](references/writing/fields.md) then [`schema/`](schema/), implement `theme.json` + `content/`, run `pack_verify.py --render`, open the PNG, and iterate until the output matches these files. Rule 6 is the final gate — the files are the plan, render is the review.

## Schema

Read-only format JSON Schemas live in [`schema/`](schema/) (same bytes the engine embeds). **Do not** copy them into an author directory — `k2f pack` injects schemas into the ZIP; hand-authored `schema/` files → `UNEXPECTED_PATH`.

1. **Allowed keys:** skim [writing/fields.md](references/writing/fields.md), then open only the schema file you are editing — `content/` → [`schema/nodes.schema.json`](schema/nodes.schema.json); `styles/theme.json` → [`schema/styles.schema.json`](schema/styles.schema.json) + [`schema/visual_primitives.schema.json`](schema/visual_primitives.schema.json); `manifest.json` → [`schema/manifest.schema.json`](schema/manifest.schema.json).
2. **First draft shapes:** copy from [`catalog/content/ex_*.json`](catalog/content/) into root `children` — golden, packable examples. See [`catalog/README.md`](catalog/README.md) for a construct index.
3. **`SCHEMA_INVALID`:** compare the failing object to the schema file. Key **in** schema but rejected → stale CLI (`pip install -U k2f`). Key **not** in schema → remove it; do not invent fields from HTML/CSS memory.
4. **Version check:** `k2f schema dump -o /tmp/k2f-schema` or `python -c "import k2f; print(k2f.format_schemas().keys())"`.

## Bundled packages

| Path | Purpose |
|------|---------|
| [`schema/`](schema/) | Read-only format JSON Schemas — lookup after [writing/fields.md](references/writing/fields.md); never copy into author dirs |
| [`starter/`](starter/) | Empty tree + core theme + Roboto — copied into `source/` when there is no existing `.K2F` and no matching Gallery package |
| [`catalog/`](catalog/) | Golden shape dictionary — copy `ex_*.json` nodes into the author dir; not a deliverable ([index](catalog/README.md)) |

© suzheng · Apache-2.0 · suzheng/k2f

Похожие скиллы

Всё по теме «Документы и офис» →
translate-book deusyu Переводит книги из PDF, DOCX и EPUB на нужный язык через параллельных субагентов. Подходит, когда результат нужно собрать в книжный формат. CX Codex +1 1 800установок llamaparse LlamaIndex Скилл для разбора неструктурированных файлов через LlamaParse: PDF, DOCX, PPTX, XLSX. Агент пишет TypeScript-скрипт, вы его запускаете. CX Codex +1 1 300установок document-processing eyadsibai Скилл для работы с офисными файлами: разбирает PDF, XLSX, DOCX и PPTX, подсказывает инструменты и правила под каждый формат. CX Codex +1 1 300установок doc-to-markdown daymade Превращает DOCX, PDF, PPTX и сохранённый HTML в аккуратный Markdown и сам чинит типовые дефекты конвертации. Пригодится, когда нужно вытащить текст из документа без ручной правки. CX Codex +1 872установок doc openai Скилл для чтения, создания и правки документов .docx, когда важна вёрстка: таблицы, разрывы страниц, шрифты. Полезен, если документ уходит клиенту. 99установок convert-documents-to-markdown firecrawl Конвертирует офисные документы, электронные таблицы и PDF в GitHub-Flavored Markdown через утилиту anydoc. Пригодится, когда агенту нужно извлечь данные из DOCX или XLSX без ручной вычитки. CX Codex +1 12 500установок

Из того же набора16

k2f-quotation Собирает клиентское коммерческое предложение из заметок по объёму работ, позиций, ставок и условий. Покупатель сравнивает варианты и принимает счёт без переделок. CX Codex +1 2 500установок k2f-sales-deck Собирает из заметок со звонков и материалов о продукте презентацию для покупателя: один сценарий встречи, боль клиента его словами, доказательства. CX Codex +1 2 500установок k2f-grant-proposal Скилл превращает заметки, предварительные данные и текст конкурса в заявку на грант с проверяемой гипотезой и независимыми задачами. CX Codex +1 2 400установок k2f-company-deck Скилл собирает из фактов о компании и бренд-материалов презентацию с позиционированием, доказательствами и контактами. Не питч для инвесторов. CX Codex +1 2 200установок k2f-purchase-order Скилл собирает заказ на закупку из заявки, котировки или списка позиций — так, чтобы поставщик отгрузил и выставил счёт без уточнений. CX Codex +1 2 200установок k2f-media-kit Скилл собирает пресс-кит для журналистов и партнёров: проверяемые факты, boilerplate и список ассетов. Работает поверх формата K2F. CX Codex +1 2 000установок k2f-academic-paper Скилл превращает заметки, данные и литературу в структуру научной рукописи: тезис, разделы, карта доказательств и план визуализаций. CX Codex +1 737установок k2f-menu Скилл превращает заметки о заведении и список блюд в читаемое меню с категориями и единым форматом цен. Работает через формат K2F и экспорт в PDF. CX Codex +1 691установок

Спонсоры проекта

Компании, которые помогают держать аналитику открытой