CLAUDE.md Python Frontend

caveman โ€” CLAUDE.md

๐Ÿชจ why use many token when few token do trick โ€” Claude Code skill that cuts 65% of tokens by talking like caveman

CLAUDE.md ยท 199 lines
# CLAUDE.md โ€” caveman

## README is a product artifact

README = product front door. Non-technical people read it to decide if caveman worth install. Treat like UI copy.

**Rules for any README change:**

- Readable by non-AI-agent users. If you write "SessionStart hook injects system context," invisible to most โ€” translate it.
- Keep Before/After examples first. That the pitch.
- Install table always complete + accurate. One broken install command costs real user.
- What You Get table must sync with actual code. Feature ships or removed โ†’ update table.
- Preserve voice. Caveman speak in README on purpose. "Brain still big." "Cost go down forever." "One rock. That it." โ€” intentional brand. Don't normalize.
- Benchmark numbers from real runs in `benchmarks/` and `evals/`. Never invent or round. Re-run if doubt.
- Adding new agent to install table โ†’ add detail block in `<details>` section below.
- Readability check before any README commit: would non-programmer understand + install within 60 seconds?

---

## Project overview

Caveman makes AI coding agents respond in compressed caveman-style prose โ€” cuts ~65-75% output tokens, full technical accuracy. Ships as Claude Code plugin, Codex plugin, Gemini CLI extension, agent rule files for Cursor, Windsurf, Cline, Copilot, 40+ others via `npx skills`.

---

## File structure and what owns what

### Single source of truth files โ€” edit only these

| File | What it controls |
|------|-----------------|
| `skills/caveman/SKILL.md` | Caveman behavior: intensity levels, rules, wenyan mode, auto-clarity, persistence. Only file to edit for behavior changes. |
| `rules/caveman-activate.md` | Always-on auto-activation rule body. CI injects into Cursor, Windsurf, Cline, Copilot rule files. Edit here, not agent-specific copies. |
| `skills/caveman-commit/SKILL.md` | Caveman commit message behavior. Fully independent skill. |
| `skills/caveman-review/SKILL.md` | Caveman code review behavior. Fully independent skill. |
| `skills/caveman-help/SKILL.md` | Quick-reference card. One-shot display, not a persistent mode. |
| `caveman-compress/SKILL.md` | Compress sub-skill behavior. |

### Auto-generated / auto-synced โ€” do not edit directly

Overwritten by CI on push to main when sources change. Edits here lost.

| File | Synced from |
|------|-------------|
| `caveman/SKILL.md` | `skills/caveman/SKILL.md` |
| `plugins/caveman/skills/caveman/SKILL.md` | `skills/caveman/SKILL.md` |
| `.cursor/skills/caveman/SKILL.md` | `skills/caveman/SKILL.md` |
| `.windsurf/skills/caveman/SKILL.md` | `skills/caveman/SKILL.md` |
| `caveman.skill` | ZIP of `skills/caveman/` directory |
| `.clinerules/caveman.md` | `rules/caveman-activate.md` |
| `.github/copilot-instructions.md` | `rules/caveman-activate.md` |
| `.cursor/rules/caveman.mdc` | `rules/caveman-activate.md` + Cursor frontmatter |
| `.windsurf/rules/caveman.md` | `rules/caveman-activate.md` + Windsurf frontmatter |

---

## CI sync workflow

`.github/workflows/sync-skill.yml` triggers on main push when `skills/caveman/SKILL.md` or `rules/caveman-activate.md` changes.

What it does:
1. Copies `skills/caveman/SKILL.md` to all agent-specific SKILL.md locations
2. Rebuilds `caveman.skill` as a ZIP of `skills/caveman/`
3. Rebuilds all agent rule files from `rules/caveman-activate.md`, prepending agent-specific frontmatter (Cursor needs `alwaysApply: true`, Windsurf needs `trigger: always_on`)
4. Commits and pushes with `[skip ci]` to avoid loops

CI bot commits as `github-actions[bot]`. After PR merge, wait for workflow before declaring release complete.

---

## Hook system (Claude Code)

Three hooks in `hooks/`. Communicate via flag file at `~/.claude/.caveman-active`.

```
SessionStart hook โ”€โ”€writes "full"โ”€โ”€โ–ถ ~/.claude/.caveman-active โ—€โ”€โ”€writes modeโ”€โ”€ UserPromptSubmit hook
                                               โ”‚
                                            reads
                                               โ–ผ
                                      caveman-statusline.sh
                                     [CAVEMAN] / [CAVEMAN:ULTRA] / ...
```

### `hooks/caveman-activate.js` โ€” SessionStart hook

Runs once per Claude Code session start. Three things:
1. Writes `"full"` to `~/.claude/.caveman-active` (creates if missing)
2. Emits caveman ruleset as hidden stdout โ€” Claude Code injects SessionStart hook stdout as system context, invisible to user
3. Checks `~/.claude/settings.json` for statusline config; if missing, appends nudge to offer setup on first interaction

Silent-fails on all filesystem errors โ€” never blocks session start.

### `hooks/caveman-mode-tracker.js` โ€” UserPromptSubmit hook

Reads JSON from stdin. Checks if prompt starts with `/caveman`. If yes, writes mode to flag file:
- `/caveman` โ†’ configured default (see `caveman-config.js`, defaults to `full`)
- `/caveman lite` โ†’ `lite`
- `/caveman ultra` โ†’ `ultra`
- `/caveman wenyan` or `/caveman wenyan-full` โ†’ `wenyan`
- `/caveman wenyan-lite` โ†’ `wenyan-lite`
- `/caveman wenyan-ultra` โ†’ `wenyan-ultra`
- `/caveman-commit` โ†’ `commit`
- `/caveman-review` โ†’ `review`
- `/caveman-compress` โ†’ `compress`

Detects "stop caveman" or "normal mode" in prompt and deletes flag file.

### `hooks/caveman-statusline.sh` โ€” Statusline badge

Reads flag file. Outputs colored badge string for Claude Code statusline:
- `full` or empty โ†’ `[CAVEMAN]` (orange)
- anything else โ†’ `[CAVEMAN:<MODE_UPPERCASED>]` (orange)

Configured in `~/.claude/settings.json` under `statusLine.command`.

### Hook installation

**Plugin install** โ€” hooks wired automatically by plugin system.

**Standalone install** โ€” `hooks/install.sh` (macOS/Linux) or `hooks/install.ps1` (Windows) copies hook files into `~/.claude/hooks/` and patches `~/.claude/settings.json` to register SessionStart and UserPromptSubmit hooks plus statusline.

**Uninstall** โ€” `hooks/uninstall.sh` / `hooks/uninstall.ps1` removes hook files and patches settings.json.

---

## Skill system

Skills = Markdown files with YAML frontmatter consumed by Claude Code's skill/plugin system and by `npx skills` for other agents.

### Intensity levels

Defined in `skills/caveman/SKILL.md`. Six levels: `lite`, `full` (default), `ultra`, `wenyan-lite`, `wenyan-full`, `wenyan-ultra`. Persists until changed or session ends.

### Auto-clarity rule

Caveman drops to normal prose for: security warnings, irreversible action confirmations, multi-step sequences where fragment ambiguity risks misread, user confused or repeating question. Resumes after. Defined in skill โ€” preserve in any SKILL.md edit.

### caveman-compress

Sub-skill in `caveman-compress/SKILL.md`. Takes file path, compresses prose to caveman style, writes to original path, saves backup at `<filename>.original.md`. Validates headings, code blocks, URLs, file paths, commands preserved. Retries up to 2 times on failure with targeted patches only. Requires Python 3.10+.

### caveman-commit / caveman-review

Independent skills in `skills/caveman-commit/SKILL.md` and `skills/caveman-review/SKILL.md`. Both have own `description` and `name` frontmatter so they load independently. caveman-commit: Conventional Commits, โ‰ค50 char subject. caveman-review: one-line comments in `L<line>: <severity> <problem>. <fix>.` format.

---

## Agent distribution

How caveman reaches each agent type:

| Agent | Mechanism | Auto-activates? |
|-------|-----------|----------------|
| Claude Code | Plugin (hooks + skills) or standalone hooks | Yes โ€” SessionStart hook injects rules |
| Codex | Plugin in `plugins/caveman/` with `hooks.json` | Yes โ€” SessionStart hook |
| Gemini CLI | Extension with `GEMINI.md` context file | Yes โ€” context file loads every session |
| Cursor | `.cursor/rules/caveman.mdc` with `alwaysApply: true` | Yes โ€” always-on rule |
| Windsurf | `.windsurf/rules/caveman.md` with `trigger: always_on` | Yes โ€” always-on rule |
| Cline | `.clinerules/caveman.md` (auto-discovered) | Yes โ€” Cline injects all .clinerules files |
| Copilot | `.github/copilot-instructions.md` + `AGENTS.md` | Yes โ€” repo-wide instructions |
| Others | `npx skills add JuliusBrussee/caveman` | No โ€” user must say `/caveman` each session |

For agents without hook systems, minimal always-on snippet lives in README under "Want it always on?" โ€” keep current with `rules/caveman-activate.md`.

---

## Evals

`evals/` has three-arm harness:
- `__baseline__` โ€” no system prompt
- `__terse__` โ€” `Answer concisely.`
- `<skill>` โ€” `Answer concisely.\n\n{SKILL.md}`

Honest delta = **skill vs terse**, not skill vs baseline. Baseline comparison conflates skill with generic terseness โ€” that cheating. Harness designed to prevent this.

`llm_run.py` calls `claude -p --system-prompt ...` per (prompt, arm), saves to `evals/snapshots/results.json`. `measure.py` reads snapshot offline with tiktoken (OpenAI BPE โ€” approximates Claude tokenizer, ratios meaningful, absolute numbers approximate).

Add skill: drop `skills/<name>/SKILL.md`. Harness auto-discovers. Add prompt: append line to `evals/prompts/en.txt`.

Snapshots committed to git. CI reads without API calls. Only regenerate when SKILL.md or prompts change.

---

## Benchmarks

`benchmarks/` runs real prompts through Claude API (not Claude Code CLI), records raw token counts. Results committed as JSON in `benchmarks/results/`. Benchmark table in README generated from results โ€” update when regenerating.

To reproduce: `uv run python benchmarks/run.py` (needs `ANTHROPIC_API_KEY` in `.env.local`).

---

## Key rules for agents working here

- Edit `skills/caveman/SKILL.md` for behavior changes. Never edit synced copies.
- Edit `rules/caveman-activate.md` for auto-activation rule changes. Never edit agent-specific rule copies.
- README most important file for user-facing impact. Optimize for non-technical readers. Preserve caveman voice.
- Benchmark and eval numbers must be real. Never fabricate or estimate.
- CI workflow commits back to main after merge. Account for when checking branch state.
- Hook files must silent-fail on all filesystem errors. Never let hook crash block session start.
Share on X

ใ“ใกใ‚‰ใ‚‚ใŠใ™ใ™ใ‚

Frontend ใ‚ซใƒ†ใ‚ดใƒชใฎไป–ใฎใƒซใƒผใƒซ

ใ‚‚ใฃใจใƒซใƒผใƒซใ‚’ๆŽขใ™

CLAUDE.mdใ€.cursorrulesใ€AGENTS.mdใ€Image Prompts ใฎๅ…จ 223 ใƒซใƒผใƒซใ‚’ใƒใ‚งใƒƒใ‚ฏใ€‚