cleanup-harden
Skill21 starsChanged 6 months agoMITView on GitHub
Runs a cleanup and hardening pass on an application or website covering security fixes, DRY consolidation, orphan and dead-code removal, doc drift, dependency audit, error handling, config validation, performance, and repo hygiene, without changing user-facing behavior. Use when the user asks to clean up, prune, harden, audit, tidy, or de-cruft a codebase, remove dead code, fix doc drift, or do a security pass.
- Reads credentials
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- content-wireframeSkill
- babysit-prSkill
- new-projectSkill
- orientSkill
- promote-skillSkill
- review-prSkill
- shipSkill
- squash-branchSkill
- release-notesSkill
- writing-ticketsSkill
- hostSkill
- advisorSkill
- sounding-boardSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
13 rules. About 0 are common, 9 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈9
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
If the user named a scope (paths, categories, or "security only"), limit the pass to it.
- Distinctive: line 20
Learn the project first: Read README, AGENTS.md / CONTRIBUTING, the package manifest, CI config, and entry points.
- Distinctive: line 22
Prove before deleting: Search the whole repo for references: string usage, dynamic imports, config, CI, scripts, docs, tests, and framework …
- Distinctive: line 45
AuthN/AuthZ: every protected route or page is actually protected.
- Very specific: line 52
Dependencies: run the ecosystem audit (npm audit, bun audit, pnpm audit, pip-audit, cargo audit, etc.).
- Distinctive: line 55
Add a regression test for each security fix where the project has tests.
- Distinctive: line 61
Put shared code where the project already keeps shared code.
- Distinctive: line 66
Delete once proven dead:
- Very specific: line 75
Use tooling when available (knip, ts-prune, depcheck, vulture, cargo udeps, etc.) but confirm each result manually.
- Distinctive: line 81
Remove docs for removed features.
- Distinctive: line 82
Delete comments that restate code or narrate history.
- Very specific: line 86
Error handling: no empty catch or swallowed promises.
- Very specific: line 88
Types/lint: remove unjustified any, @ts-ignore, lint-disable comments.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cleanup & Hardening Pass
Make the repository smaller, safer, and more accurate without changing behavior users rely on.
Scope
If the user named a scope (paths, categories, or "security only"), limit the pass to it. Otherwise run every category in order. For large codebases, finish and report security first, then continue.
Ground rules
- Learn the project first. Read README, AGENTS.md / CONTRIBUTING, the package manifest, CI config, and entry points. Find the lint, typecheck, test, and build commands and run them for a baseline. Record checks that already fail.
- Preserve behavior. Public APIs, routes, response shapes, env var names, CLI flags, and URLs stay the same unless a security fix requires otherwise. Flag any breaking change explicitly.
- Prove before deleting. Search the whole repo for references: string usage, dynamic imports, config, CI, scripts, docs, tests, and framework conventions (file-based routing, magic filenames, decorators, plugin registries). If uncertain, list it as a candidate instead of deleting.
- Small, reviewable changes. One category per commit when committing. Don't reformat untouched code.
- Match existing style. Same naming, error handling, and import conventions. No speculative abstractions.
- Verify after each category. Rerun checks; fix or revert regressions before moving on.
- Never push, deploy, force-push, or rewrite git history.
Progress checklist
- [ ] 0. Baseline: read docs, run lint/typecheck/test/build
- [ ] 1. Security
- [ ] 2. DRY consolidation
- [ ] 3. Orphan cleanup
- [ ] 4. Doc drift
- [ ] 5. Other pruning and hardening
- [ ] 6. Final verification and report1. Security
Fix confirmed issues. List anything needing a product decision instead of guessing.
- Secrets: hardcoded keys, tokens, passwords in code, tests, fixtures, docs, tracked
.envfiles. Check.gitignore. Flag secrets that need rotation; deleting doesn't remove them from history. - AuthN/AuthZ: every protected route or page is actually protected. Look for missing checks, IDOR (reaching another user's records by changing an ID), and admin/debug endpoints exposed in production.
- Input handling: validation at the boundary; SQL/NoSQL/command injection, path traversal, unsafe deserialization,
eval/ dynamicFunction. - Outbound requests: caller-supplied URLs must block private and metadata addresses, re-check redirects, and cap size and time (SSRF).
- Web: XSS (raw HTML,
dangerouslySetInnerHTML, unescaped templates), CSRF, open redirects, permissive CORS, missing headers (CSP, HSTS, X-Content-Type-Options, Referrer-Policy, frame-ancestors). - Information leaks: stack traces, raw upstream errors, internal paths, or secrets in responses, logs, or telemetry. Logs redact tokens, cookies, and bodies.
- Uploads/files: content-type and size limits, filename sanitization, safe
Content-Type/Content-Dispositionwhen serving user content. - Abuse: rate limits and timeouts on expensive or unauthenticated endpoints.
- Dependencies: run the ecosystem audit (
npm audit,bun audit,pnpm audit,pip-audit,cargo audit, etc.). Apply safe patch/minor upgrades; list majors separately. - CI/CD: pinned third-party actions, least-privilege tokens, no secrets exposed to fork PRs.
Add a regression test for each security fix where the project has tests.
2. DRY consolidation
- Find duplicated or near-duplicated logic: validation, error formatting, fetch/retry wrappers, parsing, constants, types, config loading.
- Merge only when copies mean the same thing. Code that looks alike but changes for different reasons stays separate.
- Put shared code where the project already keeps shared code; update every caller.
- Name magic numbers and repeated strings that appear three or more times.
3. Orphan cleanup
Delete once proven dead:
- unimported files, modules, components, routes, assets
- unused exports, types, constants; unreachable branches
- manifest dependencies never imported, and imported packages missing from the manifest
- stale scripts, configs for tools no longer used, unreferenced migrations/fixtures, committed build output
- commented-out code, dead feature flags, permanently-on/off flag branches
- tests for deleted code; skipped tests with no explanation
Use tooling when available (knip, ts-prune, depcheck, vulture, cargo udeps, etc.) but confirm each result manually.
4. Doc drift
- Compare README, AGENTS.md, API docs / OpenAPI,
.env.example, and inline docs against the code: endpoints, parameters, defaults, env vars, commands, ports, deploy steps. - Fix documented-but-gone and real-but-undocumented items.
.env.examplelists exactly the variables the code reads. - Remove docs for removed features. Fix broken links and relative paths.
- Delete comments that restate code or narrate history. Keep comments stating constraints the code can't show.
5. Other pruning and hardening
- Error handling: no empty
catchor swallowed promises; consistent error shapes and status codes; graceful shutdown. - Config: validate required env vars at startup with a clear message; no unsafe production defaults.
- Types/lint: remove unjustified
any,@ts-ignore, lint-disable comments; enable stricter settings when cheap. - Performance: N+1 queries, unbounded loops/pagination, missing outbound timeouts, heavy sync work on hot paths, obvious missing caching, oversized bundles/images.
- Websites: meta/OG tags,
robots.txtand sitemap accuracy, broken internal links, accessibility basics (alt text, labels, contrast, focus), dead CSS. - Tests: cover consolidated helpers that lacked coverage.
- Repo hygiene:
.gitignoregaps, large binaries, conflicting lockfiles, stale references in docs.
6. Report
Finish with this structure:
## Summary
[What changed, net lines removed]
## Security
- [file] — [severity] — [issue and what an attacker could have done] — fixed
### Needs human action
- [secret rotation, infra change, product decision]
## Changes by category
- Consolidated: ...
- Deleted: ...
- Docs updated: ...
- Hardening: ...
## Not done
- [candidate or refactor] — [reason: couldn't prove dead / risky / major upgrade]
## Verification
| Check | Before | After |
|-------|--------|-------|
| lint | | |
| typecheck | | |
| test | | |
| build | | |Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

