Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

AI Repo Gardener — Find files the AI forgot to delete

English · 繁體中文 · 简体中文 · 日本語

CI PyPI Python 3.11–3.14 GitHub prerelease

AI Repo Gardener is a deterministic garbage collector and review Skill for AI-edited Python repositories. It finds superseded files, forgotten helpers, duplicate implementations, dependency leftovers, folder pressure, and code that drifts away from the repository's own Python style—without calling a model, uploading source, or turning weak guesses into deletions.

Release status: 0.1.0a12 is the twelfth alpha in the v0.1 line. Stable 0.1.0 has not been released yet. Repo GC is the core alpha feature; architecture and house-style analysis are experimental and review-only.

Run it in 30 seconds

Python 3.11+ is required.

python -m pip install "repo-gardener==0.1.0a12"
repo-gardener diff .
repo-gardener fix . --dry-run

Or run it once without installing:

uvx --from "repo-gardener==0.1.0a12" repo-gardener diff .

diff and fix both default to --base HEAD, so the evidence shown in the review naturally carries into the dry-run. Use the same explicit Git ref on both commands when auditing another range.

A real diff and safe dry-run from AI Repo Gardener

Three evidence systems

System What it answers Status Start here
Repo GC What did the latest AI iteration replace, abandon, duplicate, or leave declared? Core alpha repo-gardener diff .
Architecture Gardener Is one directory carrying too much unrelated code, and what move plan is plausible? Experimental, review-only repo-gardener structure . --confidence all
House-style Gardener Which Python files drift from this repository's own baseline? Experimental, review-only repo-gardener style . --baseline HEAD~20 --confidence all

Repo GC includes stale-file, orphan-file, orphan-helper, duplicate-implementation, and dependency-leftover. Structure produces scored, non-mutating migration proposals. Style compares Python-specific signals—typing, paths, comprehensions, output, complexity, wrappers, defensive guards, naming, and more—against repository peers or a pre-AI commit/date. A style finding is drift evidence, never proof that AI wrote a file.

Use it as an Agent Skill

The PyPI wheel contains the complete portable Skill. Install the CLI first, then locate its bundled copy:

python -m pip install "repo-gardener==0.1.0a12"
repo-gardener skill-path

Choose one target for the agent you use. Project-level targets use the same directory names inside a repository.

Agent Personal Skill target Project Skill target Invoke
OpenAI Codex ~/.agents/skills/repo-gardener .agents/skills/repo-gardener $repo-gardener or /skills
Claude Code ~/.claude/skills/repo-gardener .claude/skills/repo-gardener /repo-gardener
Cursor ~/.cursor/skills/repo-gardener .cursor/skills/repo-gardener /repo-gardener

macOS / Linux

SKILL_SOURCE="$(repo-gardener skill-path)"

# OpenAI Codex
mkdir -p "$HOME/.agents/skills/repo-gardener"
cp -R "$SKILL_SOURCE"/. "$HOME/.agents/skills/repo-gardener/"

# Claude Code — use this instead when Claude is your host
mkdir -p "$HOME/.claude/skills/repo-gardener"
cp -R "$SKILL_SOURCE"/. "$HOME/.claude/skills/repo-gardener/"

# Cursor — use this instead when Cursor is your host
mkdir -p "$HOME/.cursor/skills/repo-gardener"
cp -R "$SKILL_SOURCE"/. "$HOME/.cursor/skills/repo-gardener/"

Windows PowerShell

$SkillSource = repo-gardener skill-path

# Pick one target:
$Target = "$HOME\.agents\skills\repo-gardener" # OpenAI Codex
# $Target = "$HOME\.claude\skills\repo-gardener" # Claude Code
# $Target = "$HOME\.cursor\skills\repo-gardener" # Cursor

New-Item -ItemType Directory -Force $Target | Out-Null
Get-ChildItem -Force $SkillSource | Copy-Item -Destination $Target -Recurse -Force

Do not install duplicate copies into several locations scanned by the same agent. The repository copy at skills/repo-gardener/ is also self-contained and follows the open Agent Skills specification.

Review first, apply exactly what you reviewed

Read-only commands never mutate the repository. A deletion requires an exact JSON plan, a second matching analysis, and a validation command:

repo-gardener fix . --dry-run --format json > reviewed-plan.json

# Review reviewed-plan.json, then apply that exact plan:
repo-gardener fix . --apply \
  --plan reviewed-plan.json \
  --validate "python -m pytest" \
  --validation-timeout 300

On PowerShell, either keep the apply command on one line or replace each \ with a PowerShell backtick. Apply validates the proposed deletion in an isolated copy before touching the original, then reverifies plan identity and file hashes. Failed validation leaves the original unchanged. Successful operations retain a recoverable snapshot for repo-gardener fix . --restore.

The plan pins the base ref and SHA, HEAD SHA, effective configuration, operation set, candidate/replacement hashes, and evidence-file hashes. A changed repository produces a different plan and is refused.

Commands

Command Purpose Mutates files?
scan . Run the supported Repo GC rules No
accept . Record the current findings as a reviewed accepted-findings ledger Ledger file only
stale . Focus on file-, symbol-, duplicate-, and dependency-level GC No
diff . [--base <ref>] Audit committed, staged, worktree, and untracked iteration changes No
fix . --dry-run Preview eligible high-confidence deletions No
fix . --dry-run --format json Create the reviewed plan contract No
fix . --apply --plan <json> --validate <cmd> Validate and apply the exact reviewed plan Yes
fix . --restore Restore the latest deletion operation Yes
structure . --confidence all Run explicit architecture analysis No
style . --baseline <ref-or-date> --confidence all Run explicit baseline-relative style analysis No
scan . --experimental Add structure and style to the full scan No
skill-path Print the portable Skill bundled in the wheel No

All reporting commands support stable JSON and SARIF 2.1.0 for agents and CI, and all of them accept --accepted <ledger>. --fail-on high, --fail-on medium, and --fail-on any return exit code 1 when the threshold is reached; tool and configuration errors return 2.

Keep it clean in CI

A repository that already has leftovers cannot be cleared in one pass. Accept today's reviewed findings once, then let CI fail only on what is new:

repo-gardener accept .                     # writes repo-gardener-accepted.json
repo-gardener scan . --accepted repo-gardener-accepted.json --fail-on medium

Each entry is a content-addressed finding ID, so it stops matching the moment the evidence changes and the finding returns for review. accept rewrites the ledger in sorted order, carries reviewer note fields forward, and drops entries that no longer reproduce. A ledger is never loaded implicitly, can only take deletion candidates away, and is pinned into the reviewed plan as accepted_sha256.

This repository is also a reusable action:

- uses: niansia/ai-repo-gardener@v0.1.0-alpha.12
  id: gardener
  with:
    command: diff
    base: ${{ github.event.pull_request.base.sha }}
    accepted: repo-gardener-accepted.json
    fail-on: high
- if: always()
  uses: github/codeql-action/upload-sarif@v4
  with:
    sarif_file: ${{ steps.gardener.outputs.sarif-file }}

It installs the exact commit it is pinned to, writes SARIF with stable fingerprints so code scanning tracks one alert instead of reopening it, prints a Markdown job summary, and never mutates the repository. Check out with fetch-depth: 0 so diff can reach its base commit.

Evidence, not vibes

These numbers describe published, reproducible gates—not population-wide accuracy claims.

Published gate Current result
Source suite 200 tests
Destructive-safety variants 0 / 59 eligible-deletion false positives
Curated labeled corpus 10 TP, 0 FP, 0 FN, 10 TN; precision and recall 100% in that corpus
Release wheel The same wheel tested on 12 OS/Python combinations: Ubuntu, Windows, macOS × Python 3.11–3.14
Pinned real repositories requests, Flask, pandas, Django, FastAPI, pytest, and Pydantic; 0 automatic-deletion candidates
Hosted style benchmark 159.11s → 97.51s from alpha.10 to alpha.11, 38.7% faster with identical findings

Read the exact fixtures, commits, machine details, and caveats:

Safety boundary

AI Repo Gardener is intentionally conservative:

  • Parse errors, opaque/dynamic loading, unresolved packaging metadata, and templated deployment commands disable automatic deletion repository-wide.
  • Framework roots, packaging entry points, public/package APIs, plugins, runtime strings, generated code, migrations, and partial replacements are protected or review-only.
  • By default, only files at the repository root can pass the automatic-delete risk gate. Files under app/, src/, packages, and namespace packages stay review-only unless the repository owner explicitly changes both relevant safety settings.
  • Architecture and style findings never move or delete files.
  • An accepted-findings ledger only suppresses reports and withholds deletion candidates. It never raises confidence, unlocks a protected path, or authorizes an apply, and it is read only when --accepted names it.
  • The tool has zero runtime dependencies, makes no model or network call, and sends no source code or telemetry.

For package-internal applications that have been reviewed, the two explicit overrides are:

[safety]
allow_delete_src = true
allow_delete_package_modules = true

Copy repo-gardener.toml.example to repo-gardener.toml for entrypoints, protected paths, exclusions, validation, and thresholds. Prefer explicit --validate commands. Repository-provided validation commands are ignored unless --trust-repo-config is supplied.

Applied operations write recoverable state under .repo-gardener/; add it to the target repository's .gitignore:

.repo-gardener/

For the complete mutation policy and JSON contract, see the safety policy and finding schema. Report a safety issue through SECURITY.md.

Development

git clone https://github.com/niansia/ai-repo-gardener.git
cd ai-repo-gardener
python -m pip install -e ".[dev]"
python -m pytest
ruff check .
ruff format --check .
python skills/repo-gardener/scripts/run_repo_gardener.py scan . --confidence all

The demo asset is reproducible with Pillow installed:

python scripts/render_demo.py

Contributions are welcome. Every false-positive fix or new evidence rule must include a reusable fixture. Read CONTRIBUTING.md before opening a pull request.

License

MIT

Metadata

Release files for repo-gardener 0.1.0a12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for repo-gardener 0.1.0a12
File Interpreter ABI Platform Actions
repo_gardener-0.1.0a12-py3-none-any.whl Python 3 none any Details for repo_gardener-0.1.0a12-py3-none-any.whl

Release files / repo_gardener-0.1.0a12-py3-none-any.whl

Download URL repo_gardener-0.1.0a12-py3-none-any.whl
Size 163.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0219d4e53f7ff2789141491b06a6407d68a3b078e3f47671f3ca50e32923c134
BLAKE2b-256 checksum
How to use checksums
dd5c4a6d13e7f80743fff3d0d38e692b18db6be83fe472af28c13f8e55eaef07
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

Security for repo-gardener 0.1.0a12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

1 file in this release has been uploaded with provenance metadata.

Attestation for repo_gardener-0.1.0a12-py3-none-any.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page