Logo von Cleanup Audit

Cleanup Audit

Community
jmagly
cleanup-audit

Audit codebase for dead code, unused exports, orphaned files, and stale manifests

Übersicht

Herausgeberjmagly
Repositoryaiwg
Skill-Namecleanup-audit
Sterne
225
Forks
34
Mitgelieferte Dateien
Nur Anweisungen
LizenzMIT
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • In sich abgeschlossen

    Alles, was das Modell braucht, steht in den Anweisungen — keine zusätzlichen Dateien zum Synchronisieren.

  • Open Source

    Von jmagly auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Cleanup Audit in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/jmagly/aiwg/tree/main/agentic/code/addons/aiwg-utils/skills/cleanup-audit
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/jmagly/aiwg.git /tmp/aiwg
mkdir -p .claude/skills
cp -r /tmp/aiwg/agentic/code/addons/aiwg-utils/skills/cleanup-audit .claude/skills/cleanup-audit
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Cleanup Audit in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Cleanup Audit automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Cleanup Audit nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

Cleanup Audit

Audits the codebase for accumulated dead weight: unused TypeScript/JS exports, orphaned source files, npm dependencies that are declared but never imported, and manifest entries that point to files that do not exist. Every finding carries a confidence rating. Only HIGH confidence findings are safe to auto-fix.

Natural Language Triggers

Users may say:

  • "cleanup audit"
  • "dead code audit"
  • "find dead code"
  • "orphan files"
  • "unused exports"
  • "cleanup analysis"
  • "find unused dependencies"
  • "stale manifest entries"
  • "what can I delete"
  • "codebase cleanup"

Parameters

--scope <path>

Restrict analysis to a subtree. Default is the full repository root.

bash
aiwg cleanup-audit --scope src/cli/
aiwg cleanup-audit --scope agentic/code/addons/

--type <exports|files|deps|manifests>

Run only the specified audit type. Omit to run all four.

ValueAudits
exportsTypeScript/JS exports with no importers
filesSource files not referenced by any import or manifest
depsnpm dependencies declared in package.json but not used in code
manifestsManifest entries (skills, agents) whose source file does not exist

Multiple types can be combined:

bash
aiwg cleanup-audit --type exports --type deps

--json

Emit findings as newline-delimited JSON to stdout instead of the formatted report. Useful for piping into other tools or CI scripts.

bash
aiwg cleanup-audit --json | jq 'select(.confidence == "HIGH")'

--fix

Auto-apply removals for all HIGH confidence findings. Has no effect without confirmation when any HIGH finding involves a non-trivial deletion (more than 10 lines or a full file). Combine with --dry-run to preview what --fix would remove.

--dry-run

Show what --fix would remove without writing any changes. If used without --fix, behaves as the default read-only audit.

Execution Flow

Phase 1: Determine Analysis Scope

  1. Parse --scope — default to repo root
  2. Parse --type — default to all four types
  3. Parse --json, --fix, --dry-run flags
  4. Build file inventory for the scope:
    • All .ts, .tsx, .js, .mjs files (for exports and files audits)
    • package.json (for deps audit)
    • All manifest.json files under agentic/ (for manifests audit)
  5. Communicate scope before analysis begins

Communicate:

Cleanup Audit
Scope: {scope}
Types: {types}
Mode: {read-only | fix | dry-run fix}

Building file inventory...
  Source files: {N}
  Manifests: {N}

Phase 2: Analyze Unused Exports

Applies to --type exports. Identifies TypeScript and JavaScript named exports that are never imported anywhere in the scope.

Detection approach:

  1. Glob all source files in scope: **/*.ts, **/*.tsx, **/*.js, **/*.mjs
  2. Extract all export declarations: export function, export class, export const, export type, export interface, export enum
  3. For each exported identifier, grep all source files for imports of that identifier
  4. An export is unused if: zero import matches AND it is not referenced in a manifest entry AND it is not a re-export pattern (export * from)

Confidence rules:

SignalConfidence
Zero imports found across entire scopeHIGH
Zero imports but identifier is a common name (e.g., index, default)MEDIUM
Zero imports but file is an entry point (index.ts, main.ts)LOW
Export appears in a barrel file (index.ts re-export)LOW — skip

Output per finding:

[UNUSED-EXPORT] HIGH
  File: src/extensions/registry.ts:45
  Export: registerExtension
  Declared: export function registerExtension(ext: Extension): void
  Importers found: 0
  Safe to remove: yes

Phase 3: Detect Orphaned Files

Applies to --type files. Identifies source files that are not imported by any other file and not listed in any manifest.

Detection approach:

  1. Build full file list for scope
  2. For each file, check whether its path appears in:
    • Any import or require statement in any other source file
    • Any manifest.json scripts or path field
    • Any package.json main, exports, or bin field
  3. A file is orphaned if none of the above references exist

Confidence rules:

SignalConfidence
No references found anywhereHIGH
No references but filename matches common entry point patternMEDIUM
No references but file is in root of package (may be undiscovered entry)LOW
Test file with no corresponding source fileMEDIUM (orphaned test)

Output per finding:

[ORPHANED-FILE] HIGH
  File: src/legacy/old-config-reader.ts
  References found: 0 (imports: 0, manifests: 0, package.json: 0)
  Last modified: 2025-11-02
  Safe to remove: yes

Phase 4: Audit Dependencies

Applies to --type deps. Finds npm packages declared in package.json that have no import or require usage anywhere in the codebase.

Detection approach:

  1. Read dependencies and devDependencies from package.json
  2. For each package name, grep source files for:
    • import ... from '{package}'
    • require('{package}')
    • import('{package}')
    • Scoped sub-path imports: import ... from '{package}/...'
  3. Also check config files for tool references: .eslintrc, jest.config.*, tsconfig.json

Confidence rules:

SignalConfidence
No import/require in source, no config referenceHIGH
No import in source but referenced in a config fileLOW — tool dependency, do not remove
No import but package name matches a peerDependencyLOW — required by consumers
No import but package is a type declaration (@types/...)MEDIUM — check if corresponding package is used

Output per finding:

[UNUSED-DEP] HIGH
  Package: lodash
  Version: ^4.17.21
  Type: dependency
  Usage in source: 0 files
  Config references: 0
  Safe to remove: yes (run: npm uninstall lodash)

Phase 5: Check Manifest Entries

Applies to --type manifests. Finds entries in manifest.json files (skills, agents, commands) whose referenced source files or directories do not exist on disk.

Detection approach:

  1. Glob all manifest.json files: **/manifest.json
  2. For each manifest, inspect entries that reference file paths:
    • skills[].scripts[]
    • agents[].path
    • commands[].handler
    • Any field ending in path, file, or script
  3. Resolve each path relative to the manifest file location
  4. Check whether the resolved path exists on disk
  5. Also flag entries where the declared name has no corresponding {name}/SKILL.md or {name}/AGENT.md directory

Confidence rules:

SignalConfidence
Declared path does not existHIGH
Declared path exists but is empty directoryMEDIUM
Name entry has no corresponding directoryHIGH
Script listed but containing skill directory has no SKILL.mdHIGH

Output per finding:

[STALE-MANIFEST] HIGH
  Manifest: agentic/code/addons/aiwg-utils/skills/manifest.json
  Entry: skills[12].name = "old-voice-converter"
  Expected path: skills/old-voice-converter/
  Path exists: no
  Safe to remove: yes (remove entry from manifest)

Phase 6: Compile Confidence-Rated Report

Aggregate all findings from Phases 2–5 into a unified report. Sort by confidence (HIGH first), then by type, then by file path.

Report format:

markdown
# Cleanup Audit Report
Generated: {timestamp}
Scope: {scope}
Types: {types}

## Summary

| Type | HIGH | MEDIUM | LOW | Total |
|------|------|--------|-----|-------|
| Unused exports | {N} | {N} | {N} | {N} |
| Orphaned files | {N} | {N} | {N} | {N} |
| Unused deps | {N} | {N} | {N} | {N} |
| Stale manifests | {N} | {N} | {N} | {N} |
| **Total** | **{N}** | **{N}** | **{N}** | **{N}** |

Auto-fixable (HIGH confidence): {N} findings

## HIGH Confidence Findings

### Unused Exports
...

### Orphaned Files
...

### Unused Dependencies
...

### Stale Manifest Entries
...

## MEDIUM Confidence Findings (manual review recommended)
...

## LOW Confidence Findings (informational)
...

## Recommended Actions

1. Run `aiwg cleanup-audit --fix` to remove {N} HIGH confidence findings automatically
2. Manually review {N} MEDIUM confidence findings
3. Ignore or suppress {N} LOW confidence findings if intentional

Save to: .aiwg/reports/cleanup-audit-{timestamp}.md

If --json flag is set, also emit each finding as a JSON object to stdout:

json
{"type": "UNUSED-EXPORT", "confidence": "HIGH", "file": "src/extensions/registry.ts", "line": 45, "detail": "registerExtension", "safe_to_remove": true}

If --fix is set (and not --dry-run), apply removals for all HIGH findings after report is generated.

Confidence Rating Reference

RatingMeaningAuto-fix eligible
HIGHStrong evidence of dead code with no false-positive signalsYes
MEDIUMLikely dead code but has signals that warrant human reviewNo
LOWInformational — pattern matches but may be intentionalNo

Never auto-fix MEDIUM or LOW findings. These exist to inform human decisions, not drive automated removal.

Error Handling

Scope Path Not Found

Error: --scope path does not exist: {path}
Verify the path is relative to the project root or use an absolute path.

Parse Failure on Manifest

Warning: Could not parse manifest at {path}
  Error: {JSON parse error}
  Action: Skipping this manifest — listed in report as PARSE_ERROR

Zero Files in Scope

Warning: No source files found in scope: {scope}
  Checked patterns: **/*.ts, **/*.tsx, **/*.js, **/*.mjs
  Confirm the scope path contains source files.

Examples

Example 1: Full audit before a release

bash
aiwg cleanup-audit

Runs all four audit types on the full repository. Generates report at .aiwg/reports/cleanup-audit-{timestamp}.md. Prints summary to stdout. No files modified.

Example 2: Auto-fix high-confidence findings

bash
aiwg cleanup-audit --fix --dry-run

Shows exactly what --fix would remove — useful for reviewing before committing. Then:

bash
aiwg cleanup-audit --fix

Removes all HIGH confidence findings: unused exports, orphaned files, stale manifest entries. For unused deps, prints the npm uninstall commands to run (does not execute them automatically).

Example 3: CI integration with JSON output

bash
aiwg cleanup-audit --type manifests --type files --json \
  | jq 'select(.confidence == "HIGH") | .file' \
  | sort -u

Extracts only HIGH confidence file-level findings as a sorted list. Suitable for a CI step that blocks merge if orphaned files are introduced.

Example 4: Scoped audit during active development

bash
aiwg cleanup-audit --scope src/cli/ --type exports

Targeted export audit for the CLI subtree only. Fast enough to run after each feature branch merge.

References

  • @$AIWG_ROOT/src/cli/handlers/utilities.ts — Cleanup audit command handler
  • @$AIWG_ROOT/agentic/code/addons/aiwg-utils/skills/manifest.json — Skills manifest (audited by manifests type)
  • @$AIWG_ROOT/docs/cli-reference.md — CLI reference for this command

Häufig gestellte Fragen

Was macht der KI-Skill Cleanup Audit?

Audit codebase for dead code, unused exports, orphaned files, and stale manifests

Warum Cleanup Audit in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Cleanup Audit besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Cleanup Audit in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/jmagly/aiwg/tree/main/agentic/code/addons/aiwg-utils/skills/cleanup-audit ein. TypingMind liest die Datei SKILL.md und installiert den Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Cleanup Audit nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Cleanup Audit verwenden?

So viele Sie möchten. In TypingMind können Sie Cleanup Audit mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Cleanup Audit kostenlos?

Ja. Der Skill wird von jmagly auf GitHub unter der Lizenz MIT veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇