# writing-lean-proofs

Guides Lean 4 proof writing and review using Mathlib conventions. Use it when formalising theorems, restructuring tactic code, or adding project checks.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 1200 installs · ★ 7805
- Author: trailofbits
- License: CC-BY-SA-4.0 · policy=link-only · description only; the file stays with the author
- Source: https://github.com/trailofbits/skills/tree/HEAD/plugins/writing-lean-proofs/skills/writing-lean-proofs/SKILL.md
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/writing-lean-proofs

## What it does

The skill starts with declarations and theorem statements, then works down to proofs. It encourages compiling a skeleton with `sorry`, isolating each goal, and using `calc` for equality chains. It also distinguishes forward helper facts with `have` from backward reductions with `suffices`.

It covers APIs around new definitions, including `ext`, `@[simp]`, coercion, and injectivity lemmas. For proof-state inspection, it uses `trace_state`, `done`, and `lake env lean Path/To/File.lean`. It also addresses slow proof terms and `maxHeartbeats` timeouts.

Its guidance follows Mathlib practice. If a Lean project has its own `CONTRIBUTING` rules, check those first; that matters more than applying this style unchanged. The skill is aimed at Lean 4 rather than Lean 3, Coq, Isabelle, or Agda.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill writing-lean-proofs -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/writing-lean-proofs/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/writing-lean-proofs/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill writing-lean-proofs -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/writing-lean-proofs/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill writing-lean-proofs -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/writing-lean-proofs/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install trailofbits/skills writing-lean-proofs
```

2. **Manually: put the files in place**
- File: `.github/skills/writing-lean-proofs/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill writing-lean-proofs -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/trailofbits/skills --path plugins/writing-lean-proofs/skills/writing-lean-proofs
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/writing-lean-proofs/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add trailofbits/skills --skill writing-lean-proofs -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/trailofbits/skills/tree/HEAD/plugins/writing-lean-proofs/skills/writing-lean-proofs/SKILL.md

## When to use it
- split a Lean 4 proof into separate lemmas
- replace `sorry` placeholders in a development
- refactor a long tactic proof into `calc` steps
- diagnose a `maxHeartbeats` timeout
- add CI checks for unproved obligations

## Example prompts
- “Create a Lean 4 proof skeleton for this theorem and leave separate steps as `sorry`.”
- “Review this Lean file against Mathlib conventions and identify lemmas to extract.”
- “Investigate the `maxHeartbeats` timeout in `Path/To/File.lean` using `trace_state`.”

## Similar
- [loogle-search](https://affpapa.org/en/nevibecode/skills/loogle-search.md) — skill · 485 installs
- [create-formal-verification-skill](https://affpapa.org/en/nevibecode/skills/create-formal-verification-skill.md) — skill · 1200 installs
- [maintain-formal-verification-skill](https://affpapa.org/en/nevibecode/skills/maintain-formal-verification-skill.md) — skill · 1100 installs
- [lean-build](https://affpapa.org/en/nevibecode/skills/lean-build.md) — skill · 104500 installs
- [writing-mstest-tests](https://affpapa.org/en/nevibecode/skills/writing-mstest-tests.md) — skill · 3400 installs
- [lean-comments](https://affpapa.org/en/nevibecode/skills/lean-comments.md) — skill · 17 installs

From the same set: [trailofbits/skills](https://affpapa.org/en/nevibecode/by/trailofbits/skills.md) — 77 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
