skill-lake-repair

Run Lean build with automatic error repair for missing cases, unused variables, and unused imports

438 stars

Best use case

skill-lake-repair is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Run Lean build with automatic error repair for missing cases, unused variables, and unused imports

Teams using skill-lake-repair should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/skill-lake-repair/SKILL.md --create-dirs "https://raw.githubusercontent.com/benbrastmckie/nvim/main/.claude/extensions/lean/skills/skill-lake-repair/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/skill-lake-repair/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How skill-lake-repair Compares

Feature / Agentskill-lake-repairStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Run Lean build with automatic error repair for missing cases, unused variables, and unused imports

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Lake Repair Skill (Direct Execution)

Direct execution skill for automated Lean build repair. Runs `lake build`, parses errors, and automatically fixes common mechanical errors in an iterative loop.

This skill executes inline without spawning a subagent.

## Execution

### Step 1: Parse Arguments

Extract flags from command input:
- `--clean`: Run `lake clean` before building
- `--max-retries N`: Maximum fix iterations (default: 3)
- `--dry-run`: Preview fixes without applying
- `--module NAME`: Build specific module only

```bash
clean=false
max_retries=3
dry_run=false
module=""

for arg in "$@"; do
  case "$arg" in
    --clean) clean=true ;;
    --dry-run) dry_run=true ;;
    --max-retries=*) max_retries="${arg#*=}" ;;
    --module=*) module="${arg#*=}" ;;
  esac
done
```

---

### Step 2: Initial Clean (Optional)

If `--clean` flag is set:

```bash
if [ "$clean" = true ]; then
  echo "Running lake clean..."
  lake clean
fi
```

---

### Step 3: Build Loop

Initialize tracking variables:
- `retry_count=0`
- `previous_errors=""` (for cycle detection)
- `total_fixes=0`

---

### Step 4: Run Build

Attempt to build the project:

```bash
if [ -n "$module" ]; then
  build_output=$(lake build "$module" 2>&1)
else
  build_output=$(lake build 2>&1)
fi
build_exit_code=$?
```

---

### Step 5: Parse Build Errors

Extract errors and warnings from build output using regex pattern:

```
Pattern: ^(.+\.lean):(\d+):(\d+): (error|warning): (.+)$
```

---

### Step 6: Classify Errors

| Error Pattern | Fix Type |
|---------------|----------|
| Missing cases | missing_cases |
| Unused variable | unused_variable |
| Unused import | unused_import |
| All other | UNFIXABLE |

---

### Step 7: Apply Fixes

#### Missing Cases Fix
Add match cases with sorry placeholders.

#### Unused Variable Fix
Rename by adding underscore prefix: `{name}` -> `_{name}`

#### Unused Import Fix
Remove the import line (only clean single-import lines).

---

### Step 8: Final Report

After loop exits:

```
Lake Build Complete
===================

Build succeeded after {retry_count} iterations.

Fixes applied:
- {file}:{line} - {description}

All modules built successfully.
```

---

## Error Handling

### MCP Tool Failure
Fall back to `lake build` via Bash.

### File Read/Write Failure
Skip that particular fix, continue with others.

### Parse Failure
Treat as unfixable error.

---

## Safety Measures

### Conservative Fixes
- All missing case fixes use `sorry` placeholders
- Unused variable fixes only add underscore prefix
- Unused import removal is cautious (single-import lines only)

### Cycle Prevention
- Track error signatures between iterations
- Stop if same errors recur
- Hard limit via max_retries (default 3)

Related Skills

skill-learn

438
from benbrastmckie/nvim

Scan codebase for FIX:/NOTE:/TODO:/QUESTION: tags and create structured tasks with interactive selection. Invoke for /learn command.

skill-deck

438
from benbrastmckie/nvim

Generate YC-style investor pitch decks in Typst

skill-todo

438
from benbrastmckie/nvim

Archive completed and abandoned tasks with CHANGE_LOG.md updates and memory harvest suggestions

skill-team-research

438
from benbrastmckie/nvim

Orchestrate multi-agent research with wave-based parallel execution. Spawns 2-4 teammates for diverse investigation angles and synthesizes findings.

skill-team-plan

438
from benbrastmckie/nvim

Orchestrate multi-agent planning with parallel plan generation. Spawns 2-3 teammates for diverse planning approaches and synthesizes into final plan with trade-off analysis.

skill-team-implement

438
from benbrastmckie/nvim

Orchestrate multi-agent implementation with parallel phase execution. Spawns teammates for independent phases and coordinates dependent phases. Includes debugger teammate for error recovery.

skill-status-sync

438
from benbrastmckie/nvim

Atomically update task status across TODO.md and state.json. For standalone use only.

skill-spawn

438
from benbrastmckie/nvim

Research blockers and spawn new tasks to overcome them, updating parent task dependencies

skill-researcher

438
from benbrastmckie/nvim

Conduct general research using web search, documentation, and codebase exploration. Invoke for general research tasks.

skill-refresh

438
from benbrastmckie/nvim

Manage Claude Code resources - terminate orphaned processes and clean up ~/.claude/ directory

skill-planner

438
from benbrastmckie/nvim

Create phased implementation plans from research findings. Invoke when a task needs an implementation plan.

skill-orchestrator

438
from benbrastmckie/nvim

Route commands to appropriate workflows based on task language and status. Invoke when executing /task, /research, /plan, /implement commands.