benbrastmckie/nvim/skill-lean-research-hard
Claude Code and agent skill by benbrastmckie/nvim
- community
Checking that the SKILL.md file is still in the repository.
Research Lean 4 and Mathlib for theorem proving tasks with hard-mode behavioral contracts. Invoke for Lean-language research using LeanSearch, Loogle, and lean-lsp tools when hard-mode is requested.
Install
npx vskill@latest install benbrastmckie/nvim/skill-lean-research-hardSKILL.md
Lean Research Hard Skill
Thin wrapper that delegates Lean hard-mode research to lean-research-hard-agent subagent.
IMPORTANT: This skill implements the skill-internal postflight pattern. After the subagent returns, this skill handles all postflight operations (status update, artifact linking, git commit) before returning.
Hard mode activates H2 (anti-analysis), H3 (lean4 reference grounding), H4 (adversarial self-verification), and H5 (divergence audit) behavioral contracts. Cost is approximately 3-5x standard lean4 research.
Trigger Conditions
This skill activates when:
- Task type is "lean4" or "lean" (either accepted)
/research N --hardis invoked for a lean4 task- Not currently routing-reachable: the routing-ladder collapse retired the skill-side
routing/
routing_hard manifest blocks and their resolver. This skill is pending migration onto hard_contracts (a separate, not-yet-dispatched follow-on); until then it is reachable only by direct invocation, not through /research --hard dispatch
Execution Flow
Stage 1: Input Validation
Validate required inputs:
task_number- Must be provided and exist in state.jsonfocus_prompt- Optional focus for research direction
Stage 1.5: Hard-Mode Cost Note
Before proceeding, emit the cost note for session tracking:
Stage 2: Preflight Status Update
Update task status to "researching" BEFORE invoking subagent.
Stage 3: Prepare Delegation Context
Prepare delegation context for the subagent:
Stage 4: Invoke Subagent
CRITICAL: You MUST use the Agent tool to spawn the subagent.
Required Tool Invocation:
When lean_readiness is non-empty, include it verbatim in the subagent prompt — the field is useless if the prompt composer drops it.
DO NOT use Skill(lean-research-hard-agent) - this will FAIL.
The subagent will:
- Apply H2 anti-analysis contract (lean4 formal proof line bar)
- Apply H3 reference grounding (5-column lemma mapping table for Tier 1)
- Execute H4 adversarial self-verification pass before returning
- Execute H5 divergence audit if focus_prompt contains "divergence" or "audit"
- Search Mathlib using lean_leansearch, lean_loogle, lean_leanfinder
- Create research report in
specs/{N}_{SLUG}/reports/ - Write metadata to
specs/{N}_{SLUG}/.return-meta.json - Return a brief text summary (NOT JSON)
Stage 4b: Self-Execution Fallback
CRITICAL: If you performed the work above WITHOUT using the Agent tool, you MUST write a .return-meta.json file now before proceeding to postflight.
If you DID use the Agent tool, skip this stage.
Postflight (ALWAYS EXECUTE)
Stage 5: Parse Subagent Return
Read the metadata file:
Stage 6: Update Task Status (Postflight)
If status is "researched", update state.json:
On partial/failed: Keep status as "researching" for resume.
Stage 7: Link Artifacts
Add artifact to state.json with summary. Update TODO.md per @.claude/context/patterns/artifact-linking-todo.md with field_name=**Research**, next_field=**Plan**.
Stage 8: Git Commit
Stage 9: Return Brief Summary
Return a brief text summary (NOT JSON). Example:
Error Handling
Input Validation Errors
Return immediately with error message if task not found.
Metadata File Missing
If subagent didn't write metadata file:
- Keep status as "researching"
- Report error to user
Git Commit Failure
Non-blocking: Log failure but continue with success response.
Subagent Timeout
Return partial status if subagent times out (default 3600s). Keep status as "researching" for resume.
MUST NOT (Postflight Boundary)
After the agent returns, this skill MUST NOT:
- Re-run Lean searches - All MCP searches are done by agent
- Re-verify type signatures - Verification is done by agent
- Edit research reports - Artifact creation is agent work
- Run adversarial verification - H4 is done by agent
The postflight phase is LIMITED TO:
- Reading agent metadata file
- Updating state.json via jq
- Updating TODO.md status marker via Edit
- Linking artifacts in state.json
- Git commit
Return Format
This skill returns a brief text summary (NOT JSON). The JSON metadata is written to the file and processed internally.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingagent-system/extensions/lean/skills/skill-lean-research-hard/SKILL.md
Popularity
- Repository stars
- 444
- Repository forks
- 464
- 7-day trend score
- 30
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/benbrastmckie/nvim/skill-lean-research-hard)