optimize

A codebase checker that looks for large files, unsafe type workarounds, unused code, dependency problems, repeated code, production console messages, and unfinished TODO notes. It can also apply safe fixes.

In plain words
What is it for?
Use it to review an existing project, find maintenance work, check dependencies, or clean up common code problems.
Why use it?
Code quality problems are easy to miss when spread across many files. This gives you one report showing what needs attention and which issues should come first.

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/nxtg-ai/forge-plugin/optimize
Clone the repo
git clone --depth 1 https://github.com/nxtg-ai/forge-plugin
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,432 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.01432
Opus 5 $0.00000 $0.00716
Sonnet 5 $0.00000 $0.00286
Haiku 4.5 $0.00000 $0.00143

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

Security

Grade A, and why

optimize 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 2d 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.

docs/commands/optimize.md · 142 lines

How it starts

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

/forge:optimize

Analyze your codebase across seven dimensions -- large files, type safety, dead code, dependencies, duplication, console statements, and TODO debt -- then optionally apply safe fixes.

Level L1 Vibe Coder
Category Quality & Testing
Syntax `/forge:optimize [--scope performance

What It Does

/forge:optimize is the codebase health scanner. It examines seven dimensions of code quality: large files that need refactoring (over 300 lines), type safety issues (as any and as unknown casts), dead code (exported symbols never imported elsewhere), dependency health (outdated, unused, and vulnerable packages), code duplication (repeated patterns across files), console statements in production code, and TODO/FIXME/HACK technical debt markers.

When the Task tool is available, the command spawns three parallel agents -- a detective for code quality, a performance agent for dependencies, and another detective for dead code -- cutting analysis time by roughly 3x compared to sequential scanning. The results are merged into a single optimization report with a 0-100 score and five prioritized recommendations.

The --fix flag enables safe automated fixes, but never without approval. It runs the full analysis first, presents a fix plan showing exactly which files will change and how, then waits for explicit confirmation before any Edit or Write operation. Safe auto-fixes include removing unused imports, replacing console.log with structured logger calls, and removing clearly dead code.

Syntax & Options

/forge:optimize [--scope performance|bundle|deps|code-quality|types] [--fix] [--report]
Option Description
--scope <area> Focus analysis on one area: performance, bundle, deps, code-quality, or types
--fix Run analysis, present fix plan, and apply safe optimizations after approval
--report Generate and save the optimization report to a file

Read the full file on GitHub · 142 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. 2d ago First seen · 142 lines · 0 tokens per session scan A d98dbdae7235

Subscribe to this mod's changes

optimize is a command published in the GitHub repository nxtg-ai/forge-plugin (5 stars, last pushed 12d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,432 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-31.