# Clean Up AI-Generated Code

AI coding sessions can leave redundant comments, defensive checks, type casts, and inconsistent style. This skill guides focused cleanup that preserves behavior and verifies changes.

## Install

```bash
npx skillstore add joseph obrien/89jobrien-ai-code-cleanup
```

## Metadata

- Status: approved
- Slug: 89jobrien-ai-code-cleanup
- Version: 1.0.1
- Author version: 1.0.1
- Skillstore revision: r1
- Version status: valid
- Tree hash: b9c77f179d79e18d843d4ac979d4547ec7f4136c27a6a46be4bfcb5e7c662bf8
- Author: Joseph OBrien
- GitHub username: 89jobrien
- License: MIT
- Repository: https://github.com/89jobrien/steve/tree/main/steve/skills/ai-code-cleanup
- Ref: c4037264bbd363c572662d6154a3ab28f5ca4f53
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, filesystem
- Quality score: 79
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/89jobrien-ai-code-cleanup
- Manifest: https://skillstore.pages.dev/api/skills/89jobrien-ai-code-cleanup/manifest

## Capabilities

- Identifies redundant comments that restate obvious code.
- Flags unnecessary defensive checks on trusted paths.
- Finds avoidable type casts and TypeScript ignore comments.
- Checks naming, formatting, imports, and declarations against local style.
- Guides surgical edits that reduce code while preserving behavior.
- Encourages compile, test, and regression checks after cleanup.

## Use Cases

- Prepare an AI-Assisted Branch: Review changed files for redundant comments, type workarounds, and defensive bloat before opening a pull request.
- Reduce Review Noise: Clean style drift and obvious generated artifacts so reviewers can focus on behavior and architecture.
- Standardize Generated Contributions: Apply project cleanup rules to code produced by different assistants before merging into the main branch.

## Prompt Templates

### Clean a Branch

```
Review this branch for AI-generated code artifacts. Remove redundant comments, unnecessary defensive checks, type workarounds, and style inconsistencies. Preserve behavior and tell me what changed.
```

### Clean Specific Files

```
Clean the files I changed in src/. Match the existing project style, keep useful comments, and remove only code that does not affect behavior. Run available checks when finished.
```

### Review Before Pull Request

```
Compare this branch with main and identify AI-generated artifacts in the changed files. Make small cleanup edits, list removed patterns, and confirm the tests or checks you ran.
```

### Plan Risky Cleanup

```
Create a cleanup plan for generated code in this module before editing. Separate safe removals from changes that need tests or reviewer approval. Then apply only the safe edits first.
```

## Limitations

- It cannot prove behavior preservation without project tests or runtime checks.
- It depends on clear project conventions to judge style accurately.
- It may need human review before removing defensive code on untrusted inputs.
- It does not replace security review or performance profiling.

## Best Practices

- Run the skill on a small diff and review each edit before merging.
- Keep defensive checks for untrusted input, external data, and security boundaries.
- Verify cleanup with the project formatter, type checker, and test suite when available.

## Anti Patterns

- Do not remove comments that explain business rules, security decisions, or non-obvious behavior.
- Do not simplify code only because it looks verbose without checking callers and tests.
- Do not apply cleanup across unrelated files in one large change.

## Security Audit

- Audited at: 2026-07-05T11:07:13.701\+00:00
- Summary: The static findings are false positives caused by Markdown fences, inline code examples, a read-only Git diff example, and regex syntax. I found no prompt injection, data exfiltration intent, network activity, credential access, or malicious command execution in the reviewed skill files.

## Stats

- Views: 261
- Downloads: 36
- Favorites: 2
- Popularity score: 0
