project-cleanup-audit
Audit and safely clean local project repositories or workspaces with excessive generated files, old project residue, dirty Git status, stale worktrees, build caches, duplicate nested projects, confusing roots, or agent context/token waste. Use when the user asks to organize a repo, remove useless files, classify valid project files, clean untracked/deleted files, reduce disk usage, migrate from an old repo layout to a canonical project, or prepare a repository for future Codex/agent work.
- License 许可
- MIT
- 最近更新
- 2026-11-07
- Stars
- ★ 11
- Forks
- 5
01 前言 Front Matter
- name
- project-cleanup-audit
- description
- Audit and safely clean local project repositories or workspaces with excessive generated files, old project residue, dirty Git status, stale worktrees, build caches, duplicate nested projects, confusing roots, or agent context/token waste. Use when the user asks to organize a repo, remove useless files, classify valid project files, clean untracked/deleted files, reduce disk usage, migrate from an old repo layout to a canonical project, or prepare a repository for future Codex/agent work.
02 资源文件 3
- 参考文档agents/openai.yaml255 B
- 参考文档references/classification.md4.0 KB
- 脚本scripts/audit_repo_cleanup.ps114.2 KB
03 SKILL.md 正文
Project Cleanup Audit
Operating Rules
Use this skill as an evidence-first cleanup workflow for local repositories. Prioritize preserving user work over reclaiming disk.
- Do not delete, reset, or overwrite until the target paths and rationale are explicit.
- If evidence is insufficient, provide only known facts, candidate hypotheses, validation paths, and temporary mitigations. Mark unverified conclusions clearly.
- Keep installed applications, user data directories, credentials, and system-wide caches out of scope unless the user explicitly includes them.
- Before structural cleanup, create a backup outside the workspace containing Git status, remotes, worktrees, patches, and copies of non-generated untracked files.
- Stop only development processes whose command line clearly points inside the workspace. Do not stop installed app processes just because the product name matches.
- Never run whole-repo
git clean -fdXunless every ignored dry-run path has been classified as safe generated residue. If the dry-run includes datasets, release artifacts, local validation output,.runtime,.codex,.codegraph, or other agent context, delete only explicit pathspecs or resolved literal paths. - Do not recursively print or quote sensitive local data directories while auditing. Prefer aggregate sizes, file counts, top-level names, and short non-sensitive samples.
Quick Audit
Run the bundled read-only audit first when PowerShell is available:
powershell -ExecutionPolicy Bypass -File "<skill>/scripts/audit_repo_cleanup.ps1" -Root . -Top 25
Use -IncludeProcesses when deletion is blocked by locked files or old dev servers:
powershell -ExecutionPolicy Bypass -File "<skill>/scripts/audit_repo_cleanup.ps1" -Root . -Top 25 -IncludeProcesses
Use -HashReleaseArtifacts only when checking whether local release packages match already-published assets. This can be slow on GB-scale archives:
powershell -ExecutionPolicy Bypass -File "<skill>/scripts/audit_repo_cleanup.ps1" -Root . -Top 25 -HashReleaseArtifacts
Read references/classification.md before classifying ambiguous files, local models, installers, datasets, dirty worktrees, or nested legacy projects.
When the audit reports Review Required Ignored Paths, treat those entries as a hard stop for whole-repo ignored cleanup. Classify them path by path before any delete.
Workflow
-
Restate the cleanup target and boundaries.
- Identify the intended canonical project, e.g. remote URL, default branch, active package manifest, app name, or repo root.
- State explicitly what will not be touched, such as installed software, user profile data, or external archives.
-
Gather read-only facts.
- Record
git rev-parse --show-toplevel, branch, HEAD, remotes,git status --short, worktrees, and top-level sizes. - Compare the current root with the canonical upstream when relevant.
- Use dry runs:
git clean -ndXfor ignored files andgit clean -ndfor untracked files. - Inspect the audit's
review_required_ignored_pathsbefore considering any ignored cleanup. - For release-heavy repositories, inspect
release_artifacts. If available, compare package names, sizes, and SHA256 values against the release host before deleting versioned archives. - Inspect
local_context_pathsbefore deleting.codex,.codegraph,.gstack,.venv,.pytest_cache, or__pycache__. - Inspect
local_data_evidence_pathsby aggregate counts and extensions; do not recursively print sensitive document names or contents. - Inspect package/build manifests:
package.json,Cargo.toml,pyproject.toml,go.mod,pom.xml,*.sln, etc.
- Record
-
Classify paths.
delete after confirmation: ignored/rebuildable build outputs, dependency installs, logs, test browser profiles, diagnostics.backup/archive first: untracked source, dirty worktrees, nested old projects, release packages not confirmed uploaded.keep: source, manifests, lockfiles, CI, docs, migrations, public assets, test fixtures.needs explicit user confirmation: local models, datasets, databases, installers, credentials, external user data.- For
build/, classify tracked packaging configuration separately from ignoredbuild/work,build/runtime, and generated metadata.
-
Back up before structural changes.
- Save status/remotes/worktrees/logs to a backup directory outside the workspace.
- Save
git diff --binarypatches for dirty tracked files. - Copy non-generated untracked files, excluding clearly rebuildable caches such as
node_modules,target,dist,.next, and browser output.
-
Execute the smallest safe cleanup.
- Prefer exact path deletion or
git clean -fdX -- <pathspec...>for ignored generated files after reviewinggit clean -ndX. - Use whole-repo
git clean -fdXonly when the ignored dry-run has no review-required paths and all entries are safe generated residue. - Use
git worktree removefor registered worktrees; do not raw-delete registered worktrees first. - Use native shell deletion with literal paths and resolved workspace-bound checks.
- On Windows, verify resolved absolute paths stay inside the workspace before recursive deletion.
- Prefer exact path deletion or
-
Handle canonical root migration only after backup.
- If the current directory is an old repo shell and the real product repo is another remote/branch/layout, switch or clone to the canonical root only after preserving dirty work.
- Do not force-delete unmerged local branches unless the user explicitly accepts losing that history.
- Prune stale remote refs and tags only after the remote is correct.
-
Verify.
- Show final
git status, branch/upstream, remotes, worktrees, top-level tree, and disk usage. - Run a minimal dependency or build dry-run when reasonable, e.g.
npm ci --dry-run --ignore-scripts. - Report any remaining locked or intentionally retained residue with reason and size.
- Show final
Output Format
When reporting results, keep the distinction clear:
- Known facts
- Cleanup actions taken
- Backups created
- Remaining risks or unverified assumptions
- Recommended next action
Never present a destructive cleanup as "fixed" if only an audit was completed.
04 同仓库更多 Skills
xhs-pharma-social-listening
Run evidence-disciplined Xiaohongshu social listening for foreign pharma employee pain points. Use when the user asks to collect and analyze notes/comments about pharma companies, aliases, roles, compliance, medical affairs, or AI topics, then produce a cited and scored sampled-insight report. Includes independent-evidence counting, MediaCrawler batch collection, and CAPTCHA/461 fallback to Agent Reach/OpenCLI.
healthcare-phi-compliance
Protected Health Information (PHI) and Personally Identifiable Information (PII) compliance patterns for healthcare applications. Covers data classification, access control, audit trails, encryption, and common leak vectors. Use when code touches PHI or PII in a healthcare system, or when auditing access control, audit trails, or leak vectors.
healthcare-eval-harness
Patient safety evaluation harness for healthcare application deployments. Automated test suites for CDSS accuracy, PHI exposure, clinical workflow integrity, and integration compliance. Blocks deployments on safety failures. Use when a healthcare deployment must be gated on patient-safety tests for CDSS accuracy, PHI exposure, and workflow integrity.
healthcare-emr-patterns
EMR/EHR development patterns for healthcare applications. Clinical safety, encounter workflows, prescription generation, clinical decision support integration, and accessibility-first UI for medical data entry. Use when building EMR or EHR features such as encounter workflows, prescription generation, or clinical data entry UI.
healthcare-cdss-patterns
Clinical Decision Support System (CDSS) development patterns. Drug interaction checking, dose validation, clinical scoring (NEWS2, qSOFA), alert severity classification, and integration into EMR workflows. Use when building clinical decision support — drug interaction checks, dose validation, clinical scoring, or alert severity.
dxy-task-clarify
用户的请求含糊、缺背景、缺资料说明、缺读者或用途时使用。先用少量带选项的追问把任务问清楚,写成任务卡,用户确认后再执行。尤其适用于医生、科研人员和药企各岗位的工作,例如「帮我分析一下这些数据」「帮我准备明天的拜访」「写个总结」「做个 PPT」「回一下这封邮件」「整理一下会议纪要」「整理一下这些文献」「帮我准备下周的讲课」「写个病例汇报」「帮我写个提示词」。用户说「先问我」「帮我理清需求」「我不知道怎么描述」「我不会问 AI」时也使用。用途、资料、读者都已说清的请求,纯翻译,以及写代码、改代码,不使用。