| name | os-cleaner |
| description | Keep Agentic OS worktree and work-item state clean after Jira terminal statuses or merged pull requests. |
OS Cleaner
Use when the user asks to clean, audit, or reconcile Agentic OS project worktrees, stateful directories, or stale work items after Jira or GitHub lifecycle closure.
Canonical workflow: harness/shared_factory/03-workflows/engineering/os_cleanup/.
This skill is an invocation mirror for that workflow, not an independent policy
source.
Load
- Route to the owning project layer.
- Read the project
worktrees/index.yml, worktrees/closed.yml when present, and active work-item lanes.
- Read the cleanup workflow or automation spec when running from
03-workflows or 04-automations.
- Refresh Jira and GitHub state only through approved tools for the current layer.
Workflow
-
Refresh cached metadata for registered worktrees:
- Jira key or URL.
- Jira status.
- Pull request URL or number.
- Pull request merged/state.
-
Run:
agentic-os project work-item infer-complete --root <os-root> --dry-run
agentic-os project worktree cleanup-closed --root <os-root> --dry-run
-
If the active work inference decisions are correct, run:
agentic-os project work-item infer-complete --root <os-root> --apply
-
If the worktree dry-run candidates are correct, run:
agentic-os project worktree cleanup-closed --root <os-root> --apply
-
Run --remove-files when the user has asked for physical checkout removal or the automation approval record explicitly allows it. For merged-PR cleanup, dirty status is not a blocker unless REOPEN.md exists.
-
Run:
agentic-os project work-item finalize-lingering --root <os-root> --apply
-
Record inference decisions, candidate counts, closed registry path, removed merged worktrees, REOPEN.md holds, and active-container index path in the worklog or automation log.
Safety Rules
- Never delete an external checkout path outside a project
worktrees/ directory.
- Never delete a reopened checkout with
REOPEN.md without asking.
- For confirmed merged PRs, delete the worktree even when it contains local dirt such as
.cursor/, .claude/, .features/, watch folders, peak-styles.css, or submodule state.
- Treat missing Jira/GitHub metadata as not eligible for automated cleanup.
- Registry cleanup is reversible from
worktrees/closed.yml; physical deletion is not.
- External writes, Jira updates, and GitHub writes still require layer approval.
Output Contract
Return:
- Cleanup mode and command run.
- Candidate count.
- Closed registry files.
- Removed symlinks or files.
- Skipped paths with reasons.
- Active container index path.