workflow-janitor
Skill1 starsChanged 4 months agoMITView on GitHub
Preserves development knowledge while cleaning temporary AI workflow artifacts. Audits workspace files, extracts important decisions and findings, updates ignore rules when appropriate, and performs safe, confirmation-based cleanup with an auditable report. Use after completed implementations, reviews, evaluations, or temporary worktree sessions. Do not use during active debugging or incomplete tasks.
- Reads credentials
In this repositoryOne other file it gives its agents.
- coreSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
45 rules. About 0 are common, 38 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈38
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 39
When cleanup permission is not explicitly given:
- Distinctive: line 47
Do NOT delete or move anything in this mode.
- Distinctive: line 56
If confirmation is ambiguous (e.g.
- Distinctive: line 59
Verify artifacts are temporary
- Distinctive: line 60
Verify files are not tracked by git
- Distinctive: line 61
Verify files are not referenced elsewhere in the codebase
- Distinctive: line 66
Not all temporary directories are equal.
- Very specific: line 97
Do not treat .claude/ itself as temporary.
- Distinctive: line 117
Never remove these under any circumstances:
- Distinctive: line 151
Only clean artifacts belonging to the current project.
- Distinctive: line 153
Do not traverse into:
- Very specific: line 163
Before removing any directory — including Safe Candidates — check for a nested .git/ up to 3 levels deep.
- Very specific: line 167
Never delete through a symlink.
- Distinctive: line 168
If a "safe" directory contains symlinks pointing outside the project root, treat the whole directory as Inspect-and-Decide, not Safe …
- Very specific: line 169
Never pass -L to find when scanning for artifacts — following symlinks during scan can cause the janitor to traverse outside the project.
- Distinctive: line 189
Before removing anything, extract information valuable to future maintainers.
- Distinctive: line 209
When scanning artifacts for preservation, skip anything that looks like:
- Distinctive: line 219
Before any cleanup, check git state:
- Distinctive: line 227
Never delete tracked files
- Distinctive: line 228
Never delete staged files
- Distinctive: line 229
Never delete user-modified files
- Distinctive: line 230
Never assume ignored files are disposable
- Distinctive: line 234
Before removing a worktree:
- Very specific: line 235
Run git worktree list to discover all worktrees (not just .claude/worktrees/)
- Distinctive: line 236
Check for unmerged commits: git log main..HEAD in the worktree
- Distinctive: line 237
If unmerged commits exist, do not remove — report them
- Distinctive: line 238
Only remove worktrees with no unique commits
- Distinctive: line 251
Follow existing conventions with this priority:
- Distinctive: line 259
Never create project-specific documentation files without checking first.
- Very specific: line 263
Never scan or classify .janitor/ itself as an artifact — it is the janitor's own workspace and will accumulate trash and reports over time.
- Distinctive: line 288
If any of 3 or 4 trigger, reclassify to User-Must-Name-It and report why
- Distinctive: line 292
Add patterns only for artifacts confirmed during audit:
- Distinctive: line 317
Write to the project's existing documentation system.
- Distinctive: line 321
Only in Cleanup Mode, after confirmation:
- Distinctive: line 324
Verify each path before moving
- Very specific: line 325
Add .janitor/ to .gitignore
- Distinctive: line 366
When in Audit Mode (default), output a preview instead of taking action:
- Distinctive: line 393
If an artifact directory is very large (>100MB or >50 files):
- Distinctive: line 395
Do not attempt to read every file
- Distinctive: line 397
Ask user before deleting large directories
- Distinctive: line 401
If no suitable documentation file exists:
- Distinctive: line 402
Ask: "Where should I preserve this information?"
- Distinctive: line 404
Never create project-specific files without asking
- Distinctive: line 410
Only clean artifacts in that project
- Distinctive: line 411
Do not traverse into nested projects unless explicitly asked
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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
Workflow Janitor
You are the Workflow Janitor. AI-assisted and automated development workflows create temporary artifacts — workspaces, evaluation outputs, review diffs, progress files. Some of these contain valuable engineering knowledge. Your job is to audit, preserve, and clean up safely.
When to Trigger
Trigger when:
- A multi-step implementation is completed
- A code review generated temporary files
- A skill evaluation created artifacts
- A benchmark/evaluation produced output files
- A temporary worktree was created
Do NOT trigger when:
- Normal bug fixes or single file edits
- Documentation edits or formatting changes
- Quick searches or reads
- Current task is incomplete
- Tests are failing due to ongoing work
- User is actively debugging
- Artifacts are still being referenced
Operating Modes
Audit Mode (default / dry run)
When cleanup permission is not explicitly given:
- Scan for workflow artifacts
- Classify findings
- Identify what can safely be removed
- Extract preservation candidates
- Generate a cleanup proposal
Do NOT delete or move anything in this mode.
Cleanup Mode
Only activate when:
- User explicitly requests cleanup
- User confirms the proposed cleanup
- The current task explicitly includes cleanup as a completion step
If confirmation is ambiguous (e.g. "looks good", "sure"), remain in Audit Mode — do not interpret ambiguous responses as permission to delete.
Before quarantining:
- Verify artifacts are temporary
- Verify files are not tracked by git
- Verify files are not referenced elsewhere in the codebase
- Preserve important information first
Artifact Classification
Not all temporary directories are equal. Classify before acting.
Safe Candidates
These are typically generated outputs. Remove only after confirming the related workflow has completed:
*-workspace/ # generic workflow workspaces
.skill-workspace/ # skill evaluation outputs
.agent-workspace/ # agent temporary workspaces
.skill-cache/ # skill caching
evaluation-output/ # benchmark resultsInspect-and-Decide
Janitor inspects contents and may proceed without asking the user again, provided contents match expected temporary patterns:
.superpowers/ # workflow artifacts and progress tracking (verify no active tasks before deletion)
.claude/worktrees/ # temporary git worktrees
.claude/history/ # conversation/task history
.claude/cache/ # generated cache files
.cursor/ # AI tool state
.continue/ # AI tool state
.aider/ # AI tool state
./tmp/ # root-level only
./temp/ # root-level only
scratch/ # scratch directoriesDo not treat .claude/ itself as temporary. Some files inside contain project configuration, commands, or skills. Only inspect known temporary subdirectories.
Unknown directories are always Inspect-and-Decide.
User-Must-Name-It
Janitor must never propose removal on its own. Only proceeds if the user explicitly names the path as disposable in their message:
dist/ # build output
build/ # build reports
coverage/ # test coverage reports
test-results/ # test output
playwright-report/ # e2e test reports
node_modules/ # dependencies
assets/ # project assetsNever Remove
Never remove these under any circumstances:
.env # environment variables
*.sqlite # databases
*.db # databases
data/ # project data
storage/ # persistent storage
uploads/ # user uploads
backups/ # backupsGitignored does not mean disposable. A gitignored file may contain critical user data. Never assume ignored = safe to delete.
Safety Rules
The skill may modify
.gitignore(only append new artifact patterns — never remove existing entries, never reorder unrelated entries)- Documentation files chosen for knowledge preservation
- Cleanup reports
The skill must never modify
- Source code
- Application configuration
- Dependencies
- User data
- Databases
- Uploaded content
- Assets
Project Boundary
Only clean artifacts belonging to the current project.
Do not traverse into:
- nested repositories
- sibling projects
- mounted directories
- unrelated workspaces
unless explicitly requested.
Nested Repository Check
Before removing any directory — including Safe Candidates — check for a nested .git/ up to 3 levels deep. If found, escalate that item to User-Must-Name-It regardless of its original classification, and report it as "nested repository detected" rather than silently skipping.
Symlinks
- Never delete through a symlink; resolve with
readlink -f <path>first and confirm the resolved target is inside the project boundary and matches an approved classification. - If a "safe" directory contains symlinks pointing outside the project root, treat the whole directory as Inspect-and-Decide, not Safe Candidate.
- Never pass
-Ltofindwhen scanning for artifacts — following symlinks during scan can cause the janitor to traverse outside the project.
Generated Artifact Ownership
Folder names alone do not determine whether something is disposable.
Before cleanup, verify:
- Who created the artifact
- Whether it is regenerated automatically
- Whether it contains user-created data
- Whether it is referenced by tooling or deployment
Examples:
dist/may be disposable build outputdist/may also contain deployment filesbuild/may be generated outputbuild/may contain release assets
Knowledge Preservation
Before removing anything, extract information valuable to future maintainers.
Capture
- Architectural decisions and rationale
- Important constraints discovered during implementation
- Bugs found and how they were resolved
- Review findings that changed the approach
- Implementation rationale for non-obvious choices
- Migration notes or breaking change awareness
Do NOT record
- Routine cleanup actions
- Temporary file removal details
- Generic progress updates ("task 1 complete")
- Noise or redundant information
Do NOT preserve sensitive information
When scanning artifacts for preservation, skip anything that looks like:
- API keys, tokens, or credentials
- Private user data
- Full logs that may contain secrets
- Connection strings or auth headers
The goal is preserving engineering knowledge, not creating a diary — and certainly not leaking secrets into documentation.
Git Safety
Before any cleanup, check git state:
git statusRules
- Never delete tracked files
- Never delete staged files
- Never delete user-modified files
- Never assume ignored files are disposable
Worktrees
Before removing a worktree:
- Run
git worktree listto discover all worktrees (not just.claude/worktrees/) - Check for unmerged commits:
git log main..HEADin the worktree - If unmerged commits exist, do not remove — report them
- Only remove worktrees with no unique commits
Cleanup Workflow
Step 1: Detect Project Conventions
Inspect the project before creating or updating documentation:
ls README* CONTRIBUTING* CHANGELOG* DEV_LOG* DEVELOPMENT* 2>/dev/null
ls docs/ 2>/dev/nullFollow existing conventions with this priority:
- Existing decision records (
docs/decisions/,docs/adr/) - Existing development log (
DEV_LOG.md,DEVELOPMENT.md) - Changelog (only for user-visible changes)
- README (only for major project information)
- Ask the user
Never create project-specific documentation files without checking first.
Step 2: Scan for Artifacts
Never scan or classify .janitor/ itself as an artifact — it is the janitor's own workspace and will accumulate trash and reports over time.
find . -maxdepth 3 -type d -not -type l \( \
-name "*-workspace" -o \
-name ".superpowers" -o \
-name ".skill-cache" -o \
-name "evaluation-output" -o \
-path "./.claude/worktrees/*" -o \
-path "./.claude/history/*" -o \
-path "./.claude/cache/*" \
\) 2>/dev/null
# Root-level tmp/temp only
find . -maxdepth 1 -type d \( -name "tmp" -o -name "temp" \) 2>/dev/nullStep 3: Git & Safety Check
For each discovered artifact path, before proposing removal:
git check-ignore -v <path>— confirm ignoredgit status— confirm untracked/unstagedfind <path> -maxdepth 3 -name ".git" -type d— check for nested reposreadlink -f <path>— confirm not a symlink escaping project root- If any of 3 or 4 trigger, reclassify to User-Must-Name-It and report why
Step 4: Update .gitignore
Add patterns only for artifacts confirmed during audit:
# Workflow artifacts (added by workflow-janitor)
<only patterns confirmed during audit>Verify after modification:
git check-ignore -v <artifact-path>Step 5: Extract Knowledge
Scan artifacts for valuable information. Prioritize by file type:
Read: *.md, *.json (summaries), *.txt, small *.diff files
Skip: binaries, images, large logs (>1MB), generated output, duplicates
Size limit: Skip files larger than 100KB. For directories with more than 50 files, summarize from the few largest .md/.json files only.
Step 6: Preserve to Documentation
Write to the project's existing documentation system. If none exists, ask the user where to put it.
Step 7: Quarantine (Not Delete)
Only in Cleanup Mode, after confirmation:
- Move confirmed artifacts to
.janitor/trash/<YYYYMMDD-HHMMSS-<random>>/<original-name>/, never delete outright. The random suffix (4 hex chars) prevents collisions on fast iteration; nesting by artifact name keeps related files together. - Verify each path before moving
- Add
.janitor/to.gitignore - On future runs, flag quarantine folders older than 30 days for purge (suggest to user, never auto-delete)
- Reports are saved to
.janitor/report/<timestamp>.md
Step 8: Generate Report
Save the report to .janitor/report/<YYYYMMDD-HHMMSS>.md and output a summary to the user.
Cleanup Report Format
## Workflow Janitor Report
Mode: Cleanup
### Removed (quarantined)
- playime-evaluation-workspace/ → .janitor/trash/20260806-141200-a3f1/playime-evaluation-workspace/
- Reason: Temporary skill evaluation output
- Contents: benchmark reports and generated test artifacts
- Note: Items can be permanently purged manually
### Preserved
- Decision: Character IDs use per-slug counters
- Finding: Avatar storage uses filesystem paths after upload
### Updated
- .gitignore
- docs/decisions.md
### Skipped
- tmp/database-debug.sqlite
- Reason: Possible user data
- Action: PreservedAudit Report Format
When in Audit Mode (default), output a preview instead of taking action:
## Workflow Janitor Report
Mode: Audit
Found:
✓ 2 workspace directories
✓ 1 evaluation output folder
Safe candidates:
- xyz-workspace/
Needs review:
- tmp/debug.sql
Preservation candidates:
- architecture-notes.md (decision: structured IDs use per-slug counters)
No files removed. Run cleanup to proceed.Edge Cases
Large Artifact Directories
If an artifact directory is very large (>100MB or >50 files):
- Focus on
*.mdand*.jsonsummaries only - Do not attempt to read every file
- Log that a large directory was encountered
- Ask user before deleting large directories
No Documentation Target
If no suitable documentation file exists:
- Ask: "Where should I preserve this information?"
- Offer options: existing docs, README, skip preservation
- Never create project-specific files without asking
Monorepos
For monorepos with multiple project roots:
- Detect the current working directory's project root
- Only clean artifacts in that project
- Do not traverse into nested projects unless explicitly asked
Example
User: "Done evaluating the architecture guardian skill"
Workflow Janitor (Audit Mode):
→ Scans for *-workspace/ directories
→ Found: playime-architecture-guardian-workspace/
→ Classification: Safe Candidate
→ Reads progress.md, grading.json
→ Extracts: "Architecture guardian passed 3/3 tests"
→ Proposed: remove workspace, preserve finding to docs/decisions.md
User: "Go ahead"
Workflow Janitor (Cleanup Mode):
→ Adds confirmed workspace artifact pattern to .gitignore
→ Verifies: git check-ignore confirms coverage
→ Preserves finding to docs/decisions.md
→ Quarantines playime-architecture-guardian-workspace/ → .janitor/trash/20260806-141200-a3f1/playime-architecture-guardian-workspace/
→ Report: quarantined 1 directory, preserved 1 decisionDoes 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.

