AI agentsThe workflow
The workflow
Each request an agent handles with census, step by step: the commands it runs, what it shows the person, and when it must ask.
This is what the census skill tells an agent to do. Every command takes --json and prints one JSON document: read exit_code and errors, not the text.
Clean junk
When the person asks to clean junk, caches or build output:
- Run
census clean --safe --json. It deletes only thesafetier: caches, build output, logs and old versions that rebuild themselves. Being asked to clean junk is the person’s approval for this tier, so don’t ask again. - Report the result in one line, from
results: freed bytes, used space before and after, and how many items were skipped. - If
results.review.itemsis more than 0, go on to review what’s left.
census clean --safe --json
{
"schema_version": 5,
"command": "clean",
"status": "ok",
"exit_code": 0,
"errors": [],
"warnings": [],
"results": {
"freed_bytes": 2041856000,
"used_before_bytes": 50146312192,
"used_after_bytes": 48104456192,
"audit": { "display": "/Users/me/Library/Application Support/census/audit/clean-1790950000000.ndjson", "lossy": false },
"items": ["…"],
"review": { "review_id": "rv-1790950000000-1a2b3c4d", "items": 14, "allocated_bytes": 6300000000 }
}
}
If the exit code isn’t 0, report errors[0].message and stop. cleanup_running means another cleanup is running: wait for it, and don’t retry in a loop.
Review what’s left
- Run
census review --json. - Show the person every item: its number,
allocated_bytesin a readable size,path,titleandreason, largest first, as listed. Items withselectable: falsecan only be chosen incensus reviewin a terminal. - Ask which to delete. Don’t suggest any: the person decides.
census review --json
{
"results": {
"review_id": "rv-1790950000000-1a2b3c4d",
"items": [
{
"path": "/Users/me/proj/foo/target",
"selectable": true,
"kind": "folder",
"rule": "cargo.target",
"title": "Cargo build output",
"reason": { "kind": "needs_review" },
"allocated_bytes": 3100000000
}
]
}
}
Delete what the person chose
- Write a JSON array of exactly the chosen
pathstrings, copied fromreview --jsonwithout changes, to a new temporary file. - Show the final list and its total once, and ask: “Permanently delete these N items (X GB)?” Wait for an explicit yes.
- Run
census apply FILE --json. - Report the freed bytes, and every item whose
outcome.resultisn’tdeleted, with its reason.
cat > /tmp/census-selection.json <<'EOF'
["/Users/me/proj/foo/target", "/Users/me/Downloads/Xcode_15.xip"]
EOF
census apply /tmp/census-selection.json --json
If apply fails with review_stale, run census review --json again and show the person the new list. Never retry with different paths without asking again.
Remove duplicate files
- Run
census duplicates --json. Show each set inresults.groups: its size,reclaimable_bytes, and every member’spath. Members markedclone: trueshare storage, so removing them frees little. - Ask which copies to delete, or which to keep. At least one copy of every set must stay; census skips a copy whose set would lose every copy.
- Write the chosen members’ paths to a selection file, confirm once (“Permanently delete these N copies (X GB)?”), then run
census apply FILE --json. - Report the freed bytes, and every copy whose
outcome.resultisn’tdeleted.
census duplicates --under ~/Downloads --json
Find large or old files
- Run
census large --json, adding--min-size SIZE,--not-opened DAYSor--folderswhen the person asks for them. Show each ofresults.items:path.display,allocated_bytesin a readable size, andopened_unix_msas a date, or “never opened” when it isnull. Items withselectable: falseare kept by a rule: say so, and don’t offer them. - Ask which to delete. Don’t suggest any: these are the person’s own files.
- Write exactly the chosen
path.displaystrings to a selection file, confirm once (“Permanently delete these N items (X GB)?”), then runcensus apply FILE --json. - Report the freed bytes, and every item whose
outcome.resultisn’tdeleted, with its reason.
census large --min-size 1G --not-opened 365 --json
Uninstall an app
- Run
census app NAME --jsonand show what an uninstall removes: the app, and eachleftoversitem withconfidencehighormediumthat is neithersharednorneeds_admin. Show the other items as kept. - Ask once: “Uninstall NAME and delete its data (X GB)?” Wait for an explicit yes. If the person wants a different set, list exactly those paths, the app’s own
pathamong them. - Run
census uninstall NAME --yes --json, adding the chosen paths as arguments when the person changed the set. - Report the freed bytes and
results.kept. Onapp_running, ask the person to quit the app. Never quit it yourself.
census app Slack --json
census uninstall Slack --yes --json
Speed up or fix the Mac
- Run
census maintain --jsonand show the tasks that match the problem, withfixes,interruptsandrestart. - Ask which to run. Before running them, say that
snapshotsdeletes local Time Machine snapshots and thatfinderstops a copy in progress. - Run
census maintain TASK ... --yes --jsonwith exactly the chosen tasks. - Report each task’s
resultanddetail, andresults.restartif it isn’t empty.
census maintain --json
census maintain quicklook open-with --yes --json
census optimize --yes --json deletes the safe tier and runs the quick tasks. Use it only when the person asks to optimize or clean up everything, after showing what it does.
Empty the Trash
- Run
census empty-trash --json. Without--yesit only lists. Showresults.count, andallocated_bytesin a readable size for each ofresults.trashes, byname. If the person wants to see or choose items, show each Trash’sitems: name, size, andtrashed_unix_msas a date. - Ask once: “Permanently delete N items (X GB) from the Trash?”, naming what stays if the person chose. Wait for an explicit yes.
- Run
census empty-trash --yes --json, adding the chosenitems[].pathstrings as arguments when the person chose only some. Report the freed bytes, and every item whoseoutcome.resultisn’tdeleted, with its reason. - On
trash_unreadable, report the message: the app running census needs Full Disk Access.
Never empty the Trash as part of cleaning junk or optimizing, only when the person asks for it.
AI agents’ own data
For the space AI coding agents take, run census findings --category ai_agents --json. Their history has safety: keep and is never deleted. See Cleaning agent data.