extract-tikz — скилл для Claude Code: TikZ в SVG из Beamer
Скилл extract-tikz для Claude Code выдёргивает TikZ-диаграммы из Beamer-исходника, компилирует в PDF и конвертирует в SVG с нумерацией с нуля. Синхронизирует слайды с Quarto.
MIT ★ 1 729 обновлён 2026-09-27
npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a claude-codeЧто делает extract-tikz
Скилл разбирает \begin{tikzpicture} в .tex-файле лекции и превращает каждый блок в отдельный SVG. Процесс жёсткий: сначала сверка с исходником, потом превентивная проверка правил, затем xelatex и pdf2svg.
Перед компиляцией скилл запускает scripts/check-tikz-prevention.py и останавливается, если масштабирование или подписи рёбер нарушают правила P3 и P4. Требуется Python 3, а для компиляции нужен xelatex и pdf2svg в системе.
Финальный этап — вызов субагента tikz-reviewer, который выносит вердикт APPROVED, NEEDS REVISION или REJECTED. Если не APPROVED, скилл возвращает правки в Beamer и повторяет цикл, максимум пять раз. Без этого цикла SVG уходят в прод с пересечениями подписей.
Какие задачи решает
- выдрать TikZ-блоки из Beamer-лекции в отдельный файл
- собрать многостраничный PDF с диаграммами
- конвертировать каждую страницу PDF в SVG
- проверить масштабирование и направления подписей до компиляции
- прогнать диаграммы через tikz-reviewer
Примеры запросов агенту
- Собери SVG для Lecture2 через extract-tikz
- TikZ-блоки в lecture2.tex поменялись, пересобери диаграммы
- Проверь extract_tikz.tex на нарушения P3/P4
Как установить extract-tikz
1Через Skills CLI (Vercel)
npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a claude-code2Вручную: положить файлы
~/.claude/skills/extract-tikz/SKILL.mdПапка скилла целиком; для одного проекта — .claude/skills/extract-tikz/
1Через Skills CLI (Vercel)
npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a codex2Вручную: положить файлы
.agents/skills/extract-tikz/SKILL.mdДля всех проектов — ~/.agents/skills/
1Через Skills CLI (Vercel)
npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a cursor2Вручную: положить файлы
.cursor/skills/extract-tikz/SKILL.mdCursor читает и .agents/skills/, и .claude/skills/
1GitHub CLI
gh skill install pedrohcgs/claude-code-my-workflow .claude/skills/extract-tikz2Вручную: положить файлы
.github/skills/extract-tikz/SKILL.md1Через Skills CLI (Vercel)
npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a gemini-cli2Командой платформы
gemini skills install https://github.com/pedrohcgs/claude-code-my-workflow --path .claude/skills/extract-tikzВручную: положить файлы
.devin/skills/extract-tikz/SKILL.mdСтарый путь .windsurf/skills/ тоже читается
Через Skills CLI (Vercel)
npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a opencodeClaude.ai
Упакуйте папку в zip и загрузите в Settings → Capabilities → Skills
По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов
Вопросы об extract-tikz
Как установить extract-tikz в Claude Code?
Выполните npx skills add pedrohcgs/claude-code-my-workflow --skill extract-tikz -a claude-code. Скилл появится в ~/.claude/skills/extract-tikz/SKILL.md.
Что делает extract-tikz?
Извлекает TikZ-диаграммы из Beamer-исходника, компилирует их в многостраничный PDF, конвертирует страницы в SVG с 0-based индексацией и гоняет через субагента tikz-reviewer для проверки пересечений и ошибок.
Что нужно для работы скилла?
Нужны xelatex, pdf2svg и Python 3. Превентивная проверка запускается скриптом scripts/check-tikz-prevention.py и требует, чтобы блоки TikZ соответствовали правилам P3 и P4.
Исходный текст
SKILL.md · MIT
---
name: extract-tikz
description: Extract TikZ diagrams from Beamer `.tex` source, compile each to a standalone PDF, and convert to SVG with 0-based indexing. Use when user says "extract the tikz", "regenerate the diagrams", "rebuild the SVGs", "sync tikz to quarto", or after editing TikZ blocks in a Beamer deck that also has a Quarto mirror.
argument-hint: "[LectureN, e.g., Lecture2]"
allowed-tools: ["Read", "Bash", "Glob", "Agent", "Task"]
---
# Extract TikZ Diagrams to SVG
Extract TikZ diagrams from the Beamer source, compile to multi-page PDF, and convert each page to SVG for use in Quarto slides.
> **Creating a brand-new diagram instead of extracting?** Use [`/new-diagram`](../new-diagram/SKILL.md) — it scaffolds from `templates/tikz-snippets/` with the prevention rules pre-applied.
## Steps
### Step 0: Freshness Check (MANDATORY)
**Before compiling, verify that `extract_tikz.tex` matches the current Beamer source.**
1. Find the Beamer source: `ls Slides/$ARGUMENTS*.tex`
2. Extract all `\begin{tikzpicture}` blocks from Beamer
3. Compare with `Figures/$ARGUMENTS/extract_tikz.tex`
4. If ANY difference exists: update extract_tikz.tex from the Beamer source
5. If extract_tikz.tex doesn't exist: create it from scratch
### Step 1: Prevention pre-check (MANDATORY — halt on violation)
Before compiling, verify every `\begin{tikzpicture}` block in `Figures/$ARGUMENTS/extract_tikz.tex` satisfies the prevention rules in [`.claude/rules/tikz-prevention.md`](../../rules/tikz-prevention.md). The pre-check is a small Python script shared with `/new-diagram` so both skills enforce identical behavior:
```bash
python3 scripts/check-tikz-prevention.py "Figures/$ARGUMENTS/extract_tikz.tex"
```
What it checks:
- **P3 — `scale=X` without node scaling.** Bare `scale=` shrinks coordinates but not text. Allowed forms: `scale=X, every node/.style={scale=X}` or `scale=X, transform shape`. The checker parses the full `\begin{tikzpicture}[...]` options block even when it spans multiple lines.
- **P4 — Directional keyword on edge labels.** Every edge label (`node` inside a `\draw`) must carry `above`, `below`, `left`, `right`, or a compound (e.g. `above left`). `midway` alone is a path position, not a direction. The checker scans the full `\draw ...;` statement so `\draw` on one line and `node[...]{...}` on the next line are still linked.
Note what the pre-check does NOT enforce: P1 (boxed-node explicit dimensions) and P2 (coordinate-map comment) are structural and get flagged by `tikz-reviewer` in Step 8, not here.
Exit codes: `0` = all files pass, `1` = one or more P3/P4 violations (stderr lists file, line, snippet, rule), `2` = usage error.
If exit is non-zero: halt, report the offending lines, and ask the user to fix the Beamer source (single source of truth). Do NOT compile.
### Step 2: Navigate to the lecture's Figures directory
```bash
cd Figures/$ARGUMENTS
```
### Step 3: Compile the extract_tikz.tex file
```bash
TEXINPUTS=../../Preambles:$TEXINPUTS xelatex -interaction=nonstopmode extract_tikz.tex
```
### Step 4: Count the number of pages
```bash
pdfinfo extract_tikz.pdf | grep "Pages:"
```
### Step 5: Convert each page to SVG using 0-BASED INDEXING
**CRITICAL: PDF pages are 1-indexed, but output SVG files are 0-indexed!**
```bash
PAGES=$(pdfinfo extract_tikz.pdf | grep "Pages:" | awk '{print $2}')
for i in $(seq 1 $PAGES); do
idx=$(printf "%02d" $((i-1)))
pdf2svg extract_tikz.pdf tikz_exact_$idx.svg $i
done
```
### Step 6: Sync to docs/ for deployment
```bash
cd ../..
./scripts/sync_to_docs.sh $ARGUMENTS
```
### Step 7: Verify SVG files
- Read 2-3 SVG files to confirm they contain valid SVG markup
- Confirm file sizes are reasonable (not 0 bytes)
### Step 8: Visual Quality Review (tikz-reviewer)
Spawn the **tikz-reviewer** agent (via the `Agent` tool with `subagent_type=tikz-reviewer`) on the TikZ source blocks to catch label overlaps, geometric errors, and visual inconsistencies. The reviewer cites specific passes and formulas from [`.claude/rules/tikz-measurement.md`](../../rules/tikz-measurement.md). If it returns **NEEDS REVISION** or **REJECTED**, loop:
1. Apply the recommended fixes to the Beamer `.tex` source (single source of truth).
2. Re-copy the updated block to `extract_tikz.tex`.
3. Re-run the prevention pre-check (Step 1) and compile.
4. Regenerate SVGs, re-sync.
5. Re-invoke tikz-reviewer.
Stop when tikz-reviewer returns **APPROVED** (max 5 rounds).
### Step 9: Report results
## Source of Truth Reminder
TikZ diagrams MUST be edited in the Beamer `.tex` file first, then copied verbatim to `extract_tikz.tex`. See `.claude/rules/single-source-of-truth.md`.
© pedrohcgs · MIT · pedrohcgs/claude-code-my-workflow