[{"data":1,"prerenderedAt":598,"buildId":599},["ShallowReactive",2],{"docs:\u002Fguide\u002Fagents":3},{"page":4,"section":16,"document":17,"credits":10,"prev":595,"next":10},{"id":5,"path":6,"file":7,"title":8,"sourceTitle":8,"description":9,"tagline":9,"eyebrow":10,"credits":10,"keywords":11,"icon":12,"layout":13,"sidebar":14,"toc":14,"kind":10,"group":10,"navigation":14,"order":15},"agents","\u002Fguide\u002Fagents","guide\u002Fagents.md","For agents","The loop a coding agent follows to free disk space with whatfrees, and the rules that keep it from deleting work.",null,[],"i-lucide-bot","article",true,7,"guide",{"nodes":18,"toc":583},[19,23,51,59,317,323,388,394,397,576],[20,21,22],"p",{},"Give an agent this prompt.",[24,25,28],"pre",{"language":26,"class":27,"wrap":14},"text","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[29,30,32,40,41,40,46],"code",{"class":31},"language-text",[33,34,37],"span",{"class":35,"style":36},"line","display: inline",[33,38,39],{},"Run npx whatfrees --json. Consider only safe entries for automatic cleanup. Leave orphan entries for a person to inspect and approve.","\n",[33,42,43],{"class":35,"style":36},[33,44,45],{},"For a safe worktrees entry, run npx whatfrees check --json \u003Cpath> right before deletion. Use the entry's own command only if the check exits with 0 and still reports safe; otherwise skip it.",[33,47,48],{"class":35,"style":36},[33,49,50],{},"Read https:\u002F\u002Fwhatfrees.loadsheet.dev\u002Fguide\u002Fagents first.",[52,53,58],"h2",{"id":54,"anchor":55},"the-loop",{"label":56,"icon":57},"Section titled \"The loop\"","#","The loop",[60,61,62,105,208,264,295],"steps",{},[63,64,66,73,90],"step",{"index":65},"1",[67,68,72],"h3",{"id":69,"anchor":70},"scan",{"label":71,"icon":57},"Section titled \"Scan\"","Scan",[24,74,77],{"language":75,"frame":76,"class":27,"wrap":14},"sh","terminal",[29,78,80],{"class":79},"language-sh",[33,81,82,86],{"class":35,"style":36},[33,83,85],{"style":84},"color:#953800;--shiki-dark:#FFA657","whatfrees",[33,87,89],{"style":88},"color:#0550AE;--shiki-dark:#79C0FF"," --json",[20,91,92,93,96,97,100,101,104],{},"Read ",[29,94,95],{},"entries",". They are sorted by ",[29,98,99],{},"bytes.frees",", biggest first. ",[29,102,103],{},"disk[].free"," is the free space before you start.",[63,106,108,114,121],{"index":107},"2",[67,109,113],{"id":110,"anchor":111},"choose",{"label":112,"icon":57},"Section titled \"Choose\"","Choose",[20,115,116,117,120],{},"Only a ",[29,118,119],{},"safe"," entry can proceed without manual review:",[122,123,124,137],"table",{},[125,126,127],"thead",{},[128,129,130,134],"tr",{},[131,132,133],"th",{},"Verdict",[131,135,136],{},"What to do",[138,139,140,150,160,178,188,198],"tbody",{},[128,141,142,147],{},[143,144,145],"td",{},[29,146,119],{},[143,148,149],{},"Go on to the next step",[128,151,152,157],{},[143,153,154],{},[29,155,156],{},"orphan",[143,158,159],{},"Leave it for a person to inspect and approve. A worktree without Git metadata may still hold the only copy of a file",[128,161,162,167],{},[143,163,164],{},[29,165,166],{},"ask",[143,168,169,170,173,174,177],{},"Show the person the ",[29,171,172],{},"what",", the ",[29,175,176],{},"evidence"," and the size, and let them decide",[128,179,180,185],{},[143,181,182],{},[29,183,184],{},"unsaved",[143,186,187],{},"Never delete. The work exists nowhere else",[128,189,190,195],{},[143,191,192],{},[29,193,194],{},"live",[143,196,197],{},"Never delete. Something uses it",[128,199,200,205],{},[143,201,202],{},[29,203,204],{},"unchecked",[143,206,207],{},"Never delete. whatfrees couldn't tell",[63,209,211,217,234,251],{"index":210},"3",[67,212,216],{"id":213,"anchor":214},"check-again",{"label":215,"icon":57},"Section titled \"Check again\"","Check again",[20,218,219,220,222,223,226,227,230,231,233],{},"For a ",[29,221,119],{}," entry from the ",[29,224,225],{},"worktrees"," source, run this right before the delete, not at the start of the session. ",[29,228,229],{},"whatfrees check"," only knows Git checkouts and the agents' leftovers; the pnpm store is always ",[29,232,166],{},".",[24,235,236],{"language":75,"frame":76,"class":27,"wrap":14},[29,237,238],{"class":79},[33,239,240,242,246,248],{"class":35,"style":36},[33,241,85],{"style":84},[33,243,245],{"style":244},"color:#0A3069;--shiki-dark:#A5D6FF"," check",[33,247,89],{"style":88},[33,249,250],{"style":244}," \u002Fhome\u002Fyou\u002F.codex\u002Fworktrees\u002F9f2c\u002Fapp",[20,252,253,254,257,258,260,261,263],{},"Go on only if the check exits with 0 and the JSON ",[29,255,256],{},"verdict"," is still ",[29,259,119],{},". Skip the entry on any error or missing verdict. If it is now ",[29,262,156],{},", leave it for manual review even if the exit code is 0.",[63,265,267,273,288],{"index":266},"4",[67,268,272],{"id":269,"anchor":270},"run-the-command",{"label":271,"icon":57},"Section titled \"Run the command\"","Run the command",[20,274,275,276,279,280,283,284,287],{},"Run the entry's ",[29,277,278],{},"command"," as it is. It is a quoted POSIX command built from a short list of known verbs, so a path with spaces or ",[29,281,282],{},"$(...)"," in it can't become a second command. If the entry has a ",[29,285,286],{},"then",", run it after, for the bytes to come back.",[20,289,290,291,294],{},"Don't add ",[29,292,293],{},"--force",". Don't swap in another command.",[63,296,298,304],{"index":297},"5",[67,299,303],{"id":300,"anchor":301},"confirm",{"label":302,"icon":57},"Section titled \"Confirm\"","Confirm",[20,305,306,307,309,310,312,313,316],{},"Run ",[29,308,85],{}," again. ",[29,311,103],{}," should have grown by about the ",[29,314,315],{},"frees"," you counted. Report both numbers.",[52,318,322],{"id":319,"anchor":320},"rules",{"label":321,"icon":57},"Section titled \"Rules\"","Rules",[324,325,326,330,339,351,369,376],"ul",{},[327,328,329],"li",{},"whatfrees deletes nothing. The agent does, and the agent is responsible for the delete.",[327,331,332,333,335,336,338],{},"A ",[29,334,119],{}," verdict is true at the time of the scan. A person or another agent may start work afterwards. That is why ",[29,337,229],{}," comes right before each delete.",[327,340,341,342,345,346,348,349,233],{},"Don't pass ",[29,343,344],{},"--all"," to find more to delete. It adds entries that are in use or small, and ",[29,347,194],{}," stays ",[29,350,194],{},[327,352,353,354,357,358,361,362,365,366,233],{},"When ",[29,355,356],{},"partial"," is ",[29,359,360],{},"true",", sizes are lower bounds or missing. Run the first ",[29,363,364],{},"next"," command to get a longer budget, or pass ",[29,367,368],{},"--exact",[327,370,371,372,375],{},"A source in ",[29,373,374],{},"skipped"," has no entries in this report. It doesn't mean the thing is empty.",[327,377,378,379,382,383,233],{},"Don't read the text report to parse it. Use ",[29,380,381],{},"--json"," and the fields in ",[384,385,387],"a",{"href":386},"\u002Freference\u002Freport","the JSON report",[52,389,393],{"id":390,"anchor":391},"in-code",{"label":392,"icon":57},"Section titled \"In code\"","In code",[20,395,396],{},"The same loop in a script.",[24,398,400],{"language":399,"class":27,"wrap":14},"ts",[29,401,403,40,422,40,424,40,445,40,464,40,486,40,502,40,521,40,538,40,555,40,560,40,571],{"class":402},"language-ts",[33,404,405,409,413,416,419],{"class":35,"style":36},[33,406,408],{"style":407},"color:#CF222E;--shiki-dark:#FF7B72","import",[33,410,412],{"style":411},"color:#1F2328;--shiki-dark:#E6EDF3"," { check, scan } ",[33,414,415],{"style":407},"from",[33,417,418],{"style":244}," \"whatfrees\"",[33,420,421],{"style":411},";",[33,423],{"class":35,"style":36},[33,425,426,429,432,435,438,442],{"class":35,"style":36},[33,427,428],{"style":407},"const",[33,430,431],{"style":88}," report",[33,433,434],{"style":407}," =",[33,436,437],{"style":407}," await",[33,439,441],{"style":440},"color:#8250DF;--shiki-dark:#D2A8FF"," scan",[33,443,444],{"style":411},"();",[33,446,447,450,453,455,458,461],{"class":35,"style":36},[33,448,449],{"style":407},"for",[33,451,452],{"style":411}," (",[33,454,428],{"style":407},[33,456,457],{"style":88}," entry",[33,459,460],{"style":407}," of",[33,462,463],{"style":411}," report.entries) {",[33,465,466,469,472,475,478,481,484],{"class":35,"style":36},[33,467,468],{"style":407},"  if",[33,470,471],{"style":411}," (entry.verdict ",[33,473,474],{"style":407},"!==",[33,476,477],{"style":244}," \"safe\"",[33,479,480],{"style":411},") ",[33,482,483],{"style":407},"continue",[33,485,421],{"style":411},[33,487,488,490,493,496,499],{"class":35,"style":36},[33,489,468],{"style":407},[33,491,492],{"style":411}," (entry.source ",[33,494,495],{"style":407},"===",[33,497,498],{"style":244}," \"worktrees\"",[33,500,501],{"style":411},") {",[33,503,504,507,510,512,515,517,519],{"class":35,"style":36},[33,505,506],{"style":407},"    if",[33,508,509],{"style":411}," (entry.path ",[33,511,495],{"style":407},[33,513,514],{"style":88}," undefined",[33,516,480],{"style":411},[33,518,483],{"style":407},[33,520,421],{"style":411},[33,522,523,526,529,531,533,535],{"class":35,"style":36},[33,524,525],{"style":407},"    const",[33,527,528],{"style":88}," answer",[33,530,434],{"style":407},[33,532,437],{"style":407},[33,534,245],{"style":440},[33,536,537],{"style":411},"(entry.path);",[33,539,540,542,545,547,549,551,553],{"class":35,"style":36},[33,541,506],{"style":407},[33,543,544],{"style":411}," (answer.verdict ",[33,546,474],{"style":407},[33,548,477],{"style":244},[33,550,480],{"style":411},[33,552,483],{"style":407},[33,554,421],{"style":411},[33,556,557],{"class":35,"style":36},[33,558,559],{"style":411},"  }",[33,561,562,565,568],{"class":35,"style":36},[33,563,564],{"style":411},"  console.",[33,566,567],{"style":440},"log",[33,569,570],{"style":411},"(entry.command);",[33,572,573],{"class":35,"style":36},[33,574,575],{"style":411},"}",[20,577,578,579,233],{},"whatfrees gives the command. Running it is up to you. See ",[384,580,582],{"href":581},"\u002Freference\u002Fapi","the JavaScript API",[584,593,594],{"id":54,"depth":585,"text":58,"children":586},2,[587,589,590,591,592],{"id":69,"depth":588,"text":72},3,{"id":110,"depth":588,"text":113},{"id":213,"depth":588,"text":216},{"id":269,"depth":588,"text":272},{"id":300,"depth":588,"text":303},{"id":319,"depth":585,"text":322},{"id":390,"depth":585,"text":393},{"path":596,"title":229,"description":597},"\u002Fguide\u002Fcheck","Re-check one path right before you delete it. It exits with 0 only when the path is safe or orphan.",1796464608642,"84b4d453-0d43-4339-8103-d1d78e551efe"]