# New Diagram

Scaffold a new TikZ diagram from the snippet gallery with prevention rules pre-applied...

- Repository: https://github.com/pedrohcgs/claude-code-my-workflow (1676 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-27
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add pedrohcgs/claude-code-my-workflow --skill new-diagram -g -a claude-code -y`
Codex: `npx skills add pedrohcgs/claude-code-my-workflow --skill new-diagram -g -a codex -y`
Cursor: `npx skills add pedrohcgs/claude-code-my-workflow --skill new-diagram -g -a cursor -y`
Gemini CLI: `npx skills add pedrohcgs/claude-code-my-workflow --skill new-diagram -g -a gemini-cli -y`

## Description

Scaffold a new TikZ diagram from the snippet gallery with prevention rules pre-applied (explicit node dimensions, coordinate map, directional edge labels). Compiles standalone, invokes tikz-reviewer with citations from tikz-measurement.md, and loops on revisions until APPROVED.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Create a New TikZ Diagram

Scaffold a diagram from `templates/tikz-snippets/`, check it against the prevention rules, compile standalone, run the reviewer with measurement citations, and loop until the diagram passes. Use this **instead of** writing TikZ from scratch; the snippets embed the invariants that `tikz-prevention.md` requires.

## Inputs

- `$0` (optional), snippet name (without `.tex`). One of the filenames in `templates/tikz-snippets/`. If omitted, list the gallery and ask the user to pick.
- `$1` (optional), output path. Defaults to `Figures/new_diagram.tex`, ask the user if this target exists so we don't clobber.

## Workflow

### Step 1: Pick a snippet

```bash
ls -1 templates/tikz-snippets/*.tex
```

Current gallery (see [`templates/tikz-snippets/README.md`](../../../templates/tikz-snippets/README.md) for descriptions):

- `dag-basic`, 3-node causal DAG (X → Y with confounder U)
- `dag-mediation`, X → M → Y with direct path
- `did-two-period`, two-period difference-in-differences
- `event-study`, event-time coefficients with 95% CIs
- `timeline`, horizontal timeline with staggered events
- `regression-scatter`, scatter + OLS fit + confidence band
- `flowchart-3step`, vertical flow with decision diamond
- `supply-demand`, supply/demand with shifted demand

If `$0` is not one of these, or is omitted, ask the user which to use.

### Step 2: Copy the snippet to the output path

```bash
SRC="templates/tikz-snippets/$0.tex"
DST="${1:-Figures/new_diagram.tex}"

# Confirm before overwriting
if [ -f "$DST" ]; then
  echo "Output path already exists: $DST"
  # Ask the user whether to overwrite. Do NOT clobber silently.
fi

mkdir -p "$(dirname "$DST")"
cp "$SRC" "$DST"
```

### Step 3: Edit the content to fit the user's intent

Ask the user what the diagram should show. Edit `$DST` with the `Edit` tool:

The rest: https://github.com/pedrohcgs/claude-code-my-workflow/blob/HEAD/.claude/skills/new-diagram/SKILL.md
