agentleFS
prantosmssprantosmss/workflow-janitor/SKILL.md

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.

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
  1. Distinctive:

    When cleanup permission is not explicitly given:

    line 39
  2. Distinctive:

    Do NOT delete or move anything in this mode.

    line 47
  3. Distinctive:

    If confirmation is ambiguous (e.g.

    line 56
  4. Distinctive:

    Verify artifacts are temporary

    line 59
  5. Distinctive:

    Verify files are not tracked by git

    line 60
  6. Distinctive:

    Verify files are not referenced elsewhere in the codebase

    line 61
  7. Distinctive:

    Not all temporary directories are equal.

    line 66
  8. Very specific:

    Do not treat .claude/ itself as temporary.

    line 97
  9. Distinctive:

    Never remove these under any circumstances:

    line 117
  10. Distinctive:

    Only clean artifacts belonging to the current project.

    line 151
  11. Distinctive:

    Do not traverse into:

    line 153
  12. Very specific:

    Before removing any directory — including Safe Candidates — check for a nested .git/ up to 3 levels deep.

    line 163
  13. Very specific:

    Never delete through a symlink.

    line 167
  14. Distinctive:

    If a "safe" directory contains symlinks pointing outside the project root, treat the whole directory as Inspect-and-Decide, not Safe …

    line 168
  15. Very specific:

    Never pass -L to find when scanning for artifacts — following symlinks during scan can cause the janitor to traverse outside the project.

    line 169
  16. Distinctive:

    Before removing anything, extract information valuable to future maintainers.

    line 189
  17. Distinctive:

    When scanning artifacts for preservation, skip anything that looks like:

    line 209
  18. Distinctive:

    Before any cleanup, check git state:

    line 219
  19. Distinctive:

    Never delete tracked files

    line 227
  20. Distinctive:

    Never delete staged files

    line 228
  21. Distinctive:

    Never delete user-modified files

    line 229
  22. Distinctive:

    Never assume ignored files are disposable

    line 230
  23. Distinctive:

    Before removing a worktree:

    line 234
  24. Very specific:

    Run git worktree list to discover all worktrees (not just .claude/worktrees/)

    line 235
  25. Distinctive:

    Check for unmerged commits: git log main..HEAD in the worktree

    line 236
  26. Distinctive:

    If unmerged commits exist, do not remove — report them

    line 237
  27. Distinctive:

    Only remove worktrees with no unique commits

    line 238
  28. Distinctive:

    Follow existing conventions with this priority:

    line 251
  29. Distinctive:

    Never create project-specific documentation files without checking first.

    line 259
  30. Very specific:

    Never scan or classify .janitor/ itself as an artifact — it is the janitor's own workspace and will accumulate trash and reports over time.

    line 263
  31. Distinctive:

    If any of 3 or 4 trigger, reclassify to User-Must-Name-It and report why

    line 288
  32. Distinctive:

    Add patterns only for artifacts confirmed during audit:

    line 292
  33. Distinctive:

    Write to the project's existing documentation system.

    line 317
  34. Distinctive:

    Only in Cleanup Mode, after confirmation:

    line 321
  35. Distinctive:

    Verify each path before moving

    line 324
  36. Very specific:

    Add .janitor/ to .gitignore

    line 325
  37. Distinctive:

    When in Audit Mode (default), output a preview instead of taking action:

    line 366
  38. Distinctive:

    If an artifact directory is very large (>100MB or >50 files):

    line 393
  39. Distinctive:

    Do not attempt to read every file

    line 395
  40. Distinctive:

    Ask user before deleting large directories

    line 397
  41. Distinctive:

    If no suitable documentation file exists:

    line 401
  42. Distinctive:

    Ask: "Where should I preserve this information?"

    line 402
  43. Distinctive:

    Never create project-specific files without asking

    line 404
  44. Distinctive:

    Only clean artifacts in that project

    line 410
  45. Distinctive:

    Do not traverse into nested projects unless explicitly asked

    line 411

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 results

Inspect-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 directories

Do 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 assets

Never Remove

Never remove these under any circumstances:

.env                      # environment variables
*.sqlite                  # databases
*.db                      # databases
data/                     # project data
storage/                  # persistent storage
uploads/                  # user uploads
backups/                  # backups

Gitignored 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 -L to find when 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 output
  • dist/ may also contain deployment files
  • build/ may be generated output
  • build/ 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 status

Rules

  • 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 list to discover all worktrees (not just .claude/worktrees/)
  • Check for unmerged commits: git log main..HEAD in 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/null

Follow existing conventions with this priority:

  1. Existing decision records (docs/decisions/, docs/adr/)
  2. Existing development log (DEV_LOG.md, DEVELOPMENT.md)
  3. Changelog (only for user-visible changes)
  4. README (only for major project information)
  5. 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/null

Step 3: Git & Safety Check

For each discovered artifact path, before proposing removal:

  1. git check-ignore -v <path> — confirm ignored
  2. git status — confirm untracked/unstaged
  3. find <path> -maxdepth 3 -name ".git" -type d — check for nested repos
  4. readlink -f <path> — confirm not a symlink escaping project root
  5. 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: Preserved

Audit 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 *.md and *.json summaries 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 decision

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.