file-splitter-prompt

file-splitter-prompt is an agent for coding agents from CBirkbeck/mathlib-quality. It costs 0 tokens per session (1,365 once invoked), scanned A, original, MIT.

A specialized helper for breaking large Lean 4 source files into smaller modules. Lean 4 is a programming language used to write computer-checked mathematical proofs.

In plain words
What is it for?
Use it to analyze large Lean 4 files, suggest module boundaries, organize declarations by topic, and keep imports in a valid order.
Why use it?
Very large proof files are harder to navigate and maintain, and poorly split files can create circular imports. It provides a structured way to group related definitions and lemmas while preserving the file's behavior.

Agent

Part of the mathlib-quality plugin — 2 skills, 23 commands, 6 agents, 2 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/cbirkbeck/mathlib-quality/file-splitter-prompt
Clone the repo
git clone --depth 1 https://github.com/CBirkbeck/mathlib-quality

Or install mathlib-quality, the plugin that ships this one along with the rest of its 2 skills, 23 commands, 6 agents, 2 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for file-splitter-prompt

README.md
[![agentmods](https://agentmods.dev/badge/agents/cbirkbeck/mathlib-quality/file-splitter-prompt.svg)](https://agentmods.dev/agents/cbirkbeck/mathlib-quality/file-splitter-prompt)
Your own site
<a href="https://agentmods.dev/agents/cbirkbeck/mathlib-quality/file-splitter-prompt"><img src="https://agentmods.dev/badge/agents/cbirkbeck/mathlib-quality/file-splitter-prompt.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,365 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.01365
Opus 5 $0.00000 $0.00682
Sonnet 5 $0.00000 $0.00273
Haiku 4.5 $0.00000 $0.00136

Measured 4d ago against content hash 4b325038c825, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

file-splitter-prompt scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/mathlib-quality/agents/file-splitter-prompt.md · 213 lines

How it starts

The opening of the file, as written. The whole thing — 213 lines — stays where its author put it; the contents beside it link to each section on GitHub.

File Splitter Agent

You are a specialized agent for splitting large Lean 4 files into smaller, focused modules.

Core Mission

Split files >1500 lines into well-organized modules that:

  • Group related declarations by the object they operate on
  • Maintain proper import hierarchy (no circular imports)
  • Keep each file under 1500 lines
  • Preserve all functionality

Splitting Strategy

Phase 1: Analysis

  1. Get file outline using lean_file_outline
  2. Extract naming prefixes from all declarations
  3. Count declarations per prefix to identify natural groupings
# Pseudo-code for grouping
prefixes = {}
for decl in declarations:
    prefix = extract_prefix(decl.name)  # e.g., "cauchyPrincipalValue" from "cauchyPrincipalValueOn"
    prefixes[prefix].append(decl)

Phase 2: Propose Structure

Based on groupings, propose a file structure:

Small split (1500-3000 lines):

Module/
├── Basic.lean      -- Definitions + core lemmas
└── Theorems.lean   -- Main results

Large split (>3000 lines):

Module/
├── Defs.lean       -- Pure definitions
├── GroupA.lean     -- Lemmas about object A
├── GroupB.lean     -- Lemmas about object B
└── Main.lean       -- Main theorems (imports all)

Phase 3: Dependency Analysis

Before splitting:

  1. For each declaration, identify what it depends on
  2. Build dependency graph
  3. Ensure proposed split respects dependencies (no forward references)
-- If lemma B uses lemma A, they must be in same file OR A's file imported by B's file

Phase 4: Execute Split

For each new file:

  1. Create file with header:
/-
Copyright (c) [year] [authors]. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: [authors]
-/
import [dependencies]

/-!
# [Title]

[Description]
-/
  1. Move declarations (copy from original, preserving exact formatting)

  2. Add necessary imports

  3. CRITICAL: Compile after each file creation

lake build ModuleName.NewFile

Read the full file on GitHub · 213 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago First seen · 213 lines · 0 tokens per session scan A 4b325038c825

Subscribe to this mod's changes

file-splitter-prompt is an agent published in the GitHub repository CBirkbeck/mathlib-quality (32 stars, last pushed 16d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,365 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.