Stage2 Build
Testing & Qualitystage2-buildStage2 Build is an Agent Skill for testing & quality published in the leanprover/lean4 repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Build and run tests against the stage2 Lean compiler. Use when asked to build, rebuild, or test against stage2.
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/leanprover/lean4/blob/HEAD/.claude/skills/stage2-build/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/stage2-build, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Testing Stage 2
Building stage2 is expensive, so confirm with the user before starting a stage2 build.
Build it as follows:
make -C build/release stage2 -j$(nproc)
Stage 2 is not automatically invalidated by changes to src/, which allows for faster iteration
when fixing a specific file in the stage 2 build. But to invalidate any files that already passed the
stage 2 build (as well as for final validation),
make -C build/release/stage2 clean-stdlib
must be run manually before building.
To rebuild individual stage 2 modules without a full make stage2, use Lake directly:
cd build/release/stage2 && lake build Init.Prelude
To run tests in stage2, replace -C build/release with -C build/release/stage2 in the usual test
commands (see the project .claude/CLAUDE.md "Running Tests" section).