cleanup

A cleanup command that finds unused or abandoned parts of a codebase, such as orphaned code, unused components, dead routes, and outdated database artifacts.

In plain words
What is it for?
Use it to inspect the project, adapt the review to its technology stack, report possible cleanup targets, and choose what to remove.
Why use it?
It helps reveal clutter and possible leftovers without deleting anything automatically, so developers can review findings before cleanup.

Command

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 commands/chappygo-os/atomic-spec/cleanup
Clone the repo
git clone --depth 1 https://github.com/Chappygo-OS/Atomic-Spec
Per session 17 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 6,250 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.00017 $0.06250
Opus 5 $0.00009 $0.03125
Sonnet 5 $0.00003 $0.01250
Haiku 4.5 $0.00002 $0.00625

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

Security

Grade A, and why

cleanup 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 3d 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.

templates/commands/cleanup.md · 846 lines

How it starts

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

User Input

$ARGUMENTS

You MUST consider the user input before proceeding (if not empty).

Purpose

This command identifies orphaned/unused code across the codebase and helps safely remove it. It adapts to the project's tech stack and gives the user full control over detection methods and cleanup actions.

⚠️ CRITICAL PRINCIPLES

  1. Report first, delete later - NEVER auto-delete. Always show findings, get user approval.
  2. Per-domain control - User chooses approach for each domain (frontend, backend, database) independently.
  3. Adapt to what exists - Only offer cleanup for domains that actually exist in the project.
  4. External tools are optional - User can always choose AI-based detection instead.

Phase 1: Project Analysis

1.0 Load Project Defaults Registry

Per Constitution Article IX, Directive 7 - Load registry first.

Read specs/_defaults/registry.yaml to get authoritative tech stack information:

  1. Extract tech stack from registry:

    • architecture.pattern, architecture.layers - System structure
    • code_patterns.data_access - Expected data access patterns
    • backend.language, backend.framework, backend.orm
    • frontend.framework, frontend.ui_library
    • database.type, database.query_style
  2. Registry provides ground truth for what technologies SHOULD be in use. If cleanup finds code using technologies NOT in registry, flag as potential orphan.

1.1 Detect Project Structure

Read plan.md from the current feature directory (or project root) to extract tech stack. Also cross-reference with specs/_defaults/registry.yaml for authoritative defaults.

Determine which domains exist:

┌─────────────────────────────────────────────────────────────┐
│ Domain Detection                                            │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│ FRONTEND exists if ANY of:                                  │
│ ├── frontend/ directory exists                              │
│ ├── src/components/ exists                                  │
│ ├── package.json has react/vue/angular/svelte               │
│ └── plan.md mentions frontend framework                     │
│                                                             │
│ BACKEND exists if ANY of:                                   │
│ ├── backend/ directory exists                               │
│ ├── app/ or src/ with routes/api folders                    │
│ ├── requirements.txt / pyproject.toml / go.mod              │
│ └── plan.md mentions backend framework                      │
│                                                             │
│ DATABASE exists if ANY of:                                  │
│ ├── migrations/ directory exists                            │
│ ├── prisma/ or drizzle/ or alembic/ directories             │
│ ├── models/ with ORM definitions                            │
│ └── plan.md mentions database/ORM                           │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Read the full file on GitHub · 846 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. 3d ago First seen · 846 lines · 17 tokens per session scan A 256b6db9302b

Subscribe to this mod's changes

cleanup is a command published in the GitHub repository Chappygo-OS/Atomic-Spec (10 stars, last pushed 10d ago), licensed MIT. It adds 17 tokens to every session and 6,250 once invoked, about $0.0001 per session on Opus 5. 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-31.