[{"data":1,"prerenderedAt":1135},["ShallowReactive",2],{"guide:/guides/claude-code-sessions-registry":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"tag":10,"date":11,"body":12,"_type":1129,"_id":1130,"_source":1131,"_file":1132,"_stem":1133,"_extension":1134},"/guides/claude-code-sessions-registry","guides",false,"","What Claude Code knows about its own sessions","Claude Code keeps a small registry of every session it starts, with the pid, the working directory and the current status. It is undocumented, it is easy to read, and it lies unless you check one thing first.","Workflow","2026-09-05",{"type":13,"children":14,"toc":1121},"root",[15,32,37,44,58,115,120,431,436,602,608,613,621,642,647,653,658,876,881,937,957,1027,1040,1046,1051,1072,1077,1083,1088,1093,1099,1104,1115],{"type":16,"tag":17,"props":18,"children":19},"element","p",{},[20,23,30],{"type":21,"value":22},"text","If you ",{"type":16,"tag":24,"props":25,"children":27},"a",{"href":26},"/guides/multiple-claude-code-sessions",[28],{"type":21,"value":29},"run several Claude Code sessions at once",{"type":21,"value":31},", sooner or later you want a script that answers \"what is running right now, and where?\". Hooks tell you when something happens, but they cannot tell you what was already going before your script started.",{"type":16,"tag":17,"props":33,"children":34},{},[35],{"type":21,"value":36},"Claude Code writes the answer to disk, and almost nobody knows it is there.",{"type":16,"tag":38,"props":39,"children":41},"h2",{"id":40},"the-registry",[42],{"type":21,"value":43},"The registry",{"type":16,"tag":17,"props":45,"children":46},{},[47,49,56],{"type":21,"value":48},"Look in ",{"type":16,"tag":50,"props":51,"children":53},"code",{"className":52},[],[54],{"type":21,"value":55},"~/.claude/sessions/",{"type":21,"value":57},". There is one JSON file per session, named after the process id:",{"type":16,"tag":59,"props":60,"children":64},"pre",{"code":61,"language":62,"meta":7,"className":63,"style":7},"$ ls ~/.claude/sessions/\n1301.json  1324.json  3940.json  ...\n","bash","language-bash shiki shiki-themes github-light github-dark",[65],{"type":16,"tag":50,"props":66,"children":67},{"__ignoreMap":7},[68,91],{"type":16,"tag":69,"props":70,"children":73},"span",{"class":71,"line":72},"line",1,[74,80,86],{"type":16,"tag":69,"props":75,"children":77},{"style":76},"--shiki-default:#6F42C1;--shiki-dark:#B392F0",[78],{"type":21,"value":79},"$",{"type":16,"tag":69,"props":81,"children":83},{"style":82},"--shiki-default:#032F62;--shiki-dark:#9ECBFF",[84],{"type":21,"value":85}," ls",{"type":16,"tag":69,"props":87,"children":88},{"style":82},[89],{"type":21,"value":90}," ~/.claude/sessions/\n",{"type":16,"tag":69,"props":92,"children":94},{"class":71,"line":93},2,[95,100,105,110],{"type":16,"tag":69,"props":96,"children":97},{"style":76},[98],{"type":21,"value":99},"1301.json",{"type":16,"tag":69,"props":101,"children":102},{"style":82},[103],{"type":21,"value":104},"  1324.json",{"type":16,"tag":69,"props":106,"children":107},{"style":82},[108],{"type":21,"value":109},"  3940.json",{"type":16,"tag":69,"props":111,"children":112},{"style":82},[113],{"type":21,"value":114},"  ...\n",{"type":16,"tag":17,"props":116,"children":117},{},[118],{"type":21,"value":119},"Each one is a compact snapshot of that session:",{"type":16,"tag":59,"props":121,"children":125},{"code":122,"language":123,"meta":7,"className":124,"style":7},"{\n  \"pid\": 1324,\n  \"sessionId\": \"2b96cc05-8c0a-4b86-bb4e-1cac777a8241\",\n  \"cwd\": \"/home/you/work/api\",\n  \"startedAt\": 1788555799810,\n  \"procStart\": \"2277\",\n  \"version\": \"2.1.261\",\n  \"kind\": \"interactive\",\n  \"entrypoint\": \"cli\",\n  \"name\": \"API\",\n  \"nameSource\": \"user\",\n  \"updatedAt\": 1788587245699,\n  \"status\": \"busy\",\n  \"statusUpdatedAt\": 1788587245699\n}\n","json","language-json shiki shiki-themes github-light github-dark",[126],{"type":16,"tag":50,"props":127,"children":128},{"__ignoreMap":7},[129,138,162,184,206,228,250,272,294,316,338,360,382,404,422],{"type":16,"tag":69,"props":130,"children":131},{"class":71,"line":72},[132],{"type":16,"tag":69,"props":133,"children":135},{"style":134},"--shiki-default:#24292E;--shiki-dark:#E1E4E8",[136],{"type":21,"value":137},"{\n",{"type":16,"tag":69,"props":139,"children":140},{"class":71,"line":93},[141,147,152,157],{"type":16,"tag":69,"props":142,"children":144},{"style":143},"--shiki-default:#005CC5;--shiki-dark:#79B8FF",[145],{"type":21,"value":146},"  \"pid\"",{"type":16,"tag":69,"props":148,"children":149},{"style":134},[150],{"type":21,"value":151},": ",{"type":16,"tag":69,"props":153,"children":154},{"style":143},[155],{"type":21,"value":156},"1324",{"type":16,"tag":69,"props":158,"children":159},{"style":134},[160],{"type":21,"value":161},",\n",{"type":16,"tag":69,"props":163,"children":165},{"class":71,"line":164},3,[166,171,175,180],{"type":16,"tag":69,"props":167,"children":168},{"style":143},[169],{"type":21,"value":170},"  \"sessionId\"",{"type":16,"tag":69,"props":172,"children":173},{"style":134},[174],{"type":21,"value":151},{"type":16,"tag":69,"props":176,"children":177},{"style":82},[178],{"type":21,"value":179},"\"2b96cc05-8c0a-4b86-bb4e-1cac777a8241\"",{"type":16,"tag":69,"props":181,"children":182},{"style":134},[183],{"type":21,"value":161},{"type":16,"tag":69,"props":185,"children":187},{"class":71,"line":186},4,[188,193,197,202],{"type":16,"tag":69,"props":189,"children":190},{"style":143},[191],{"type":21,"value":192},"  \"cwd\"",{"type":16,"tag":69,"props":194,"children":195},{"style":134},[196],{"type":21,"value":151},{"type":16,"tag":69,"props":198,"children":199},{"style":82},[200],{"type":21,"value":201},"\"/home/you/work/api\"",{"type":16,"tag":69,"props":203,"children":204},{"style":134},[205],{"type":21,"value":161},{"type":16,"tag":69,"props":207,"children":209},{"class":71,"line":208},5,[210,215,219,224],{"type":16,"tag":69,"props":211,"children":212},{"style":143},[213],{"type":21,"value":214},"  \"startedAt\"",{"type":16,"tag":69,"props":216,"children":217},{"style":134},[218],{"type":21,"value":151},{"type":16,"tag":69,"props":220,"children":221},{"style":143},[222],{"type":21,"value":223},"1788555799810",{"type":16,"tag":69,"props":225,"children":226},{"style":134},[227],{"type":21,"value":161},{"type":16,"tag":69,"props":229,"children":231},{"class":71,"line":230},6,[232,237,241,246],{"type":16,"tag":69,"props":233,"children":234},{"style":143},[235],{"type":21,"value":236},"  \"procStart\"",{"type":16,"tag":69,"props":238,"children":239},{"style":134},[240],{"type":21,"value":151},{"type":16,"tag":69,"props":242,"children":243},{"style":82},[244],{"type":21,"value":245},"\"2277\"",{"type":16,"tag":69,"props":247,"children":248},{"style":134},[249],{"type":21,"value":161},{"type":16,"tag":69,"props":251,"children":253},{"class":71,"line":252},7,[254,259,263,268],{"type":16,"tag":69,"props":255,"children":256},{"style":143},[257],{"type":21,"value":258},"  \"version\"",{"type":16,"tag":69,"props":260,"children":261},{"style":134},[262],{"type":21,"value":151},{"type":16,"tag":69,"props":264,"children":265},{"style":82},[266],{"type":21,"value":267},"\"2.1.261\"",{"type":16,"tag":69,"props":269,"children":270},{"style":134},[271],{"type":21,"value":161},{"type":16,"tag":69,"props":273,"children":275},{"class":71,"line":274},8,[276,281,285,290],{"type":16,"tag":69,"props":277,"children":278},{"style":143},[279],{"type":21,"value":280},"  \"kind\"",{"type":16,"tag":69,"props":282,"children":283},{"style":134},[284],{"type":21,"value":151},{"type":16,"tag":69,"props":286,"children":287},{"style":82},[288],{"type":21,"value":289},"\"interactive\"",{"type":16,"tag":69,"props":291,"children":292},{"style":134},[293],{"type":21,"value":161},{"type":16,"tag":69,"props":295,"children":297},{"class":71,"line":296},9,[298,303,307,312],{"type":16,"tag":69,"props":299,"children":300},{"style":143},[301],{"type":21,"value":302},"  \"entrypoint\"",{"type":16,"tag":69,"props":304,"children":305},{"style":134},[306],{"type":21,"value":151},{"type":16,"tag":69,"props":308,"children":309},{"style":82},[310],{"type":21,"value":311},"\"cli\"",{"type":16,"tag":69,"props":313,"children":314},{"style":134},[315],{"type":21,"value":161},{"type":16,"tag":69,"props":317,"children":319},{"class":71,"line":318},10,[320,325,329,334],{"type":16,"tag":69,"props":321,"children":322},{"style":143},[323],{"type":21,"value":324},"  \"name\"",{"type":16,"tag":69,"props":326,"children":327},{"style":134},[328],{"type":21,"value":151},{"type":16,"tag":69,"props":330,"children":331},{"style":82},[332],{"type":21,"value":333},"\"API\"",{"type":16,"tag":69,"props":335,"children":336},{"style":134},[337],{"type":21,"value":161},{"type":16,"tag":69,"props":339,"children":341},{"class":71,"line":340},11,[342,347,351,356],{"type":16,"tag":69,"props":343,"children":344},{"style":143},[345],{"type":21,"value":346},"  \"nameSource\"",{"type":16,"tag":69,"props":348,"children":349},{"style":134},[350],{"type":21,"value":151},{"type":16,"tag":69,"props":352,"children":353},{"style":82},[354],{"type":21,"value":355},"\"user\"",{"type":16,"tag":69,"props":357,"children":358},{"style":134},[359],{"type":21,"value":161},{"type":16,"tag":69,"props":361,"children":363},{"class":71,"line":362},12,[364,369,373,378],{"type":16,"tag":69,"props":365,"children":366},{"style":143},[367],{"type":21,"value":368},"  \"updatedAt\"",{"type":16,"tag":69,"props":370,"children":371},{"style":134},[372],{"type":21,"value":151},{"type":16,"tag":69,"props":374,"children":375},{"style":143},[376],{"type":21,"value":377},"1788587245699",{"type":16,"tag":69,"props":379,"children":380},{"style":134},[381],{"type":21,"value":161},{"type":16,"tag":69,"props":383,"children":385},{"class":71,"line":384},13,[386,391,395,400],{"type":16,"tag":69,"props":387,"children":388},{"style":143},[389],{"type":21,"value":390},"  \"status\"",{"type":16,"tag":69,"props":392,"children":393},{"style":134},[394],{"type":21,"value":151},{"type":16,"tag":69,"props":396,"children":397},{"style":82},[398],{"type":21,"value":399},"\"busy\"",{"type":16,"tag":69,"props":401,"children":402},{"style":134},[403],{"type":21,"value":161},{"type":16,"tag":69,"props":405,"children":407},{"class":71,"line":406},14,[408,413,417],{"type":16,"tag":69,"props":409,"children":410},{"style":143},[411],{"type":21,"value":412},"  \"statusUpdatedAt\"",{"type":16,"tag":69,"props":414,"children":415},{"style":134},[416],{"type":21,"value":151},{"type":16,"tag":69,"props":418,"children":419},{"style":143},[420],{"type":21,"value":421},"1788587245699\n",{"type":16,"tag":69,"props":423,"children":425},{"class":71,"line":424},15,[426],{"type":16,"tag":69,"props":427,"children":428},{"style":134},[429],{"type":21,"value":430},"}\n",{"type":16,"tag":17,"props":432,"children":433},{},[434],{"type":21,"value":435},"The fields that earn their keep:",{"type":16,"tag":437,"props":438,"children":439},"table",{},[440,459],{"type":16,"tag":441,"props":442,"children":443},"thead",{},[444],{"type":16,"tag":445,"props":446,"children":447},"tr",{},[448,454],{"type":16,"tag":449,"props":450,"children":451},"th",{},[452],{"type":21,"value":453},"Field",{"type":16,"tag":449,"props":455,"children":456},{},[457],{"type":21,"value":458},"What you get",{"type":16,"tag":460,"props":461,"children":462},"tbody",{},[463,481,498,523,577],{"type":16,"tag":445,"props":464,"children":465},{},[466,476],{"type":16,"tag":467,"props":468,"children":469},"td",{},[470],{"type":16,"tag":50,"props":471,"children":473},{"className":472},[],[474],{"type":21,"value":475},"cwd",{"type":16,"tag":467,"props":477,"children":478},{},[479],{"type":21,"value":480},"The directory the session runs in. This is the one that is genuinely hard to get any other way.",{"type":16,"tag":445,"props":482,"children":483},{},[484,493],{"type":16,"tag":467,"props":485,"children":486},{},[487],{"type":16,"tag":50,"props":488,"children":490},{"className":489},[],[491],{"type":21,"value":492},"sessionId",{"type":16,"tag":467,"props":494,"children":495},{},[496],{"type":21,"value":497},"The same id hooks put in their payload, so you can join the two exactly.",{"type":16,"tag":445,"props":499,"children":500},{},[501,510],{"type":16,"tag":467,"props":502,"children":503},{},[504],{"type":16,"tag":50,"props":505,"children":507},{"className":506},[],[508],{"type":21,"value":509},"name",{"type":16,"tag":467,"props":511,"children":512},{},[513,515,521],{"type":21,"value":514},"The session name, with ",{"type":16,"tag":50,"props":516,"children":518},{"className":517},[],[519],{"type":21,"value":520},"nameSource",{"type":21,"value":522}," telling you whether you set it or it was derived.",{"type":16,"tag":445,"props":524,"children":525},{},[526,535],{"type":16,"tag":467,"props":527,"children":528},{},[529],{"type":16,"tag":50,"props":530,"children":532},{"className":531},[],[533],{"type":21,"value":534},"status",{"type":16,"tag":467,"props":536,"children":537},{},[538,544,546,552,553,559,561,567,569,575],{"type":16,"tag":50,"props":539,"children":541},{"className":540},[],[542],{"type":21,"value":543},"busy",{"type":21,"value":545},", ",{"type":16,"tag":50,"props":547,"children":549},{"className":548},[],[550],{"type":21,"value":551},"idle",{"type":21,"value":545},{"type":16,"tag":50,"props":554,"children":556},{"className":555},[],[557],{"type":21,"value":558},"waiting",{"type":21,"value":560}," or ",{"type":16,"tag":50,"props":562,"children":564},{"className":563},[],[565],{"type":21,"value":566},"shell",{"type":21,"value":568},", as of ",{"type":16,"tag":50,"props":570,"children":572},{"className":571},[],[573],{"type":21,"value":574},"statusUpdatedAt",{"type":21,"value":576},".",{"type":16,"tag":445,"props":578,"children":579},{},[580,597],{"type":16,"tag":467,"props":581,"children":582},{},[583,589,591],{"type":16,"tag":50,"props":584,"children":586},{"className":585},[],[587],{"type":21,"value":588},"pid",{"type":21,"value":590}," / ",{"type":16,"tag":50,"props":592,"children":594},{"className":593},[],[595],{"type":21,"value":596},"procStart",{"type":16,"tag":467,"props":598,"children":599},{},[600],{"type":21,"value":601},"The process, and a token to tell it apart from a later process that reused the number.",{"type":16,"tag":38,"props":603,"children":605},{"id":604},"the-catch-nothing-cleans-it-up",[606],{"type":21,"value":607},"The catch: nothing cleans it up",{"type":16,"tag":17,"props":609,"children":610},{},[611],{"type":21,"value":612},"Read it naively and you will be badly wrong. The files are not removed when a session ends. On the machine this guide was written on:",{"type":16,"tag":59,"props":614,"children":616},{"code":615},"40 files in ~/.claude/sessions/\n 2 processes actually alive\n",[617],{"type":16,"tag":50,"props":618,"children":619},{"__ignoreMap":7},[620],{"type":21,"value":615},{"type":16,"tag":17,"props":622,"children":623},{},[624,626,632,634,640],{"type":21,"value":625},"Some of those files were four months old and still said ",{"type":16,"tag":50,"props":627,"children":629},{"className":628},[],[630],{"type":21,"value":631},"\"status\": \"busy\"",{"type":21,"value":633},". The registry is a ",{"type":16,"tag":635,"props":636,"children":637},"strong",{},[638],{"type":21,"value":639},"last known state",{"type":21,"value":641},", not a list of what is running. A session that crashes, or that you close with the window, leaves its file behind saying whatever it happened to be doing at the time.",{"type":16,"tag":17,"props":643,"children":644},{},[645],{"type":21,"value":646},"So the file answers \"where was this session, and what was it called\". It does not answer \"is it alive\". For that you need one more step.",{"type":16,"tag":38,"props":648,"children":650},{"id":649},"reading-it-correctly",[651],{"type":21,"value":652},"Reading it correctly",{"type":16,"tag":17,"props":654,"children":655},{},[656],{"type":21,"value":657},"Take the registry as your list of candidates, then keep only the ones whose process is still there. On macOS or Linux:",{"type":16,"tag":59,"props":659,"children":661},{"code":660,"language":62,"meta":7,"className":63,"style":7},"#!/usr/bin/env bash\n# Live Claude Code sessions: cwd, name and status.\nfor f in ~/.claude/sessions/*.json; do\n  pid=$(jq -r '.pid' \"$f\" 2>/dev/null) || continue\n  kill -0 \"$pid\" 2>/dev/null || continue          # gone? skip it\n  jq -r '[.pid, .status, .name // \"-\", .cwd] | @tsv' \"$f\"\ndone\n",[662],{"type":16,"tag":50,"props":663,"children":664},{"__ignoreMap":7},[665,674,682,716,789,838,868],{"type":16,"tag":69,"props":666,"children":667},{"class":71,"line":72},[668],{"type":16,"tag":69,"props":669,"children":671},{"style":670},"--shiki-default:#6A737D;--shiki-dark:#6A737D",[672],{"type":21,"value":673},"#!/usr/bin/env bash\n",{"type":16,"tag":69,"props":675,"children":676},{"class":71,"line":93},[677],{"type":16,"tag":69,"props":678,"children":679},{"style":670},[680],{"type":21,"value":681},"# Live Claude Code sessions: cwd, name and status.\n",{"type":16,"tag":69,"props":683,"children":684},{"class":71,"line":164},[685,691,696,701,706,711],{"type":16,"tag":69,"props":686,"children":688},{"style":687},"--shiki-default:#D73A49;--shiki-dark:#F97583",[689],{"type":21,"value":690},"for",{"type":16,"tag":69,"props":692,"children":693},{"style":134},[694],{"type":21,"value":695}," f ",{"type":16,"tag":69,"props":697,"children":698},{"style":687},[699],{"type":21,"value":700},"in",{"type":16,"tag":69,"props":702,"children":703},{"style":82},[704],{"type":21,"value":705}," ~/.claude/sessions/*.json",{"type":16,"tag":69,"props":707,"children":708},{"style":134},[709],{"type":21,"value":710},"; ",{"type":16,"tag":69,"props":712,"children":713},{"style":687},[714],{"type":21,"value":715},"do\n",{"type":16,"tag":69,"props":717,"children":718},{"class":71,"line":186},[719,724,729,734,739,744,749,754,759,764,769,774,779,784],{"type":16,"tag":69,"props":720,"children":721},{"style":134},[722],{"type":21,"value":723},"  pid",{"type":16,"tag":69,"props":725,"children":726},{"style":687},[727],{"type":21,"value":728},"=",{"type":16,"tag":69,"props":730,"children":731},{"style":134},[732],{"type":21,"value":733},"$(",{"type":16,"tag":69,"props":735,"children":736},{"style":76},[737],{"type":21,"value":738},"jq",{"type":16,"tag":69,"props":740,"children":741},{"style":143},[742],{"type":21,"value":743}," -r",{"type":16,"tag":69,"props":745,"children":746},{"style":82},[747],{"type":21,"value":748}," '.pid'",{"type":16,"tag":69,"props":750,"children":751},{"style":82},[752],{"type":21,"value":753}," \"",{"type":16,"tag":69,"props":755,"children":756},{"style":134},[757],{"type":21,"value":758},"$f",{"type":16,"tag":69,"props":760,"children":761},{"style":82},[762],{"type":21,"value":763},"\"",{"type":16,"tag":69,"props":765,"children":766},{"style":687},[767],{"type":21,"value":768}," 2>",{"type":16,"tag":69,"props":770,"children":771},{"style":82},[772],{"type":21,"value":773},"/dev/null",{"type":16,"tag":69,"props":775,"children":776},{"style":134},[777],{"type":21,"value":778},") ",{"type":16,"tag":69,"props":780,"children":781},{"style":687},[782],{"type":21,"value":783},"||",{"type":16,"tag":69,"props":785,"children":786},{"style":687},[787],{"type":21,"value":788}," continue\n",{"type":16,"tag":69,"props":790,"children":791},{"class":71,"line":208},[792,797,802,806,811,815,819,823,828,833],{"type":16,"tag":69,"props":793,"children":794},{"style":143},[795],{"type":21,"value":796},"  kill",{"type":16,"tag":69,"props":798,"children":799},{"style":143},[800],{"type":21,"value":801}," -0",{"type":16,"tag":69,"props":803,"children":804},{"style":82},[805],{"type":21,"value":753},{"type":16,"tag":69,"props":807,"children":808},{"style":134},[809],{"type":21,"value":810},"$pid",{"type":16,"tag":69,"props":812,"children":813},{"style":82},[814],{"type":21,"value":763},{"type":16,"tag":69,"props":816,"children":817},{"style":687},[818],{"type":21,"value":768},{"type":16,"tag":69,"props":820,"children":821},{"style":82},[822],{"type":21,"value":773},{"type":16,"tag":69,"props":824,"children":825},{"style":687},[826],{"type":21,"value":827}," ||",{"type":16,"tag":69,"props":829,"children":830},{"style":687},[831],{"type":21,"value":832}," continue",{"type":16,"tag":69,"props":834,"children":835},{"style":670},[836],{"type":21,"value":837},"          # gone? skip it\n",{"type":16,"tag":69,"props":839,"children":840},{"class":71,"line":230},[841,846,850,855,859,863],{"type":16,"tag":69,"props":842,"children":843},{"style":76},[844],{"type":21,"value":845},"  jq",{"type":16,"tag":69,"props":847,"children":848},{"style":143},[849],{"type":21,"value":743},{"type":16,"tag":69,"props":851,"children":852},{"style":82},[853],{"type":21,"value":854}," '[.pid, .status, .name // \"-\", .cwd] | @tsv'",{"type":16,"tag":69,"props":856,"children":857},{"style":82},[858],{"type":21,"value":753},{"type":16,"tag":69,"props":860,"children":861},{"style":134},[862],{"type":21,"value":758},{"type":16,"tag":69,"props":864,"children":865},{"style":82},[866],{"type":21,"value":867},"\"\n",{"type":16,"tag":69,"props":869,"children":870},{"class":71,"line":252},[871],{"type":16,"tag":69,"props":872,"children":873},{"style":687},[874],{"type":21,"value":875},"done\n",{"type":16,"tag":17,"props":877,"children":878},{},[879],{"type":21,"value":880},"On Windows, ask for the process list instead:",{"type":16,"tag":59,"props":882,"children":886},{"code":883,"language":884,"meta":7,"className":885,"style":7},"Get-ChildItem \"$env:USERPROFILE\\.claude\\sessions\\*.json\" | ForEach-Object {\n  $s = Get-Content $_ -Raw | ConvertFrom-Json\n  if (Get-Process -Id $s.pid -ErrorAction SilentlyContinue) {\n    \"{0}`t{1}`t{2}`t{3}\" -f $s.pid, $s.status, $s.name, $s.cwd\n  }\n}\n","powershell","language-powershell shiki shiki-themes github-light github-dark",[887],{"type":16,"tag":50,"props":888,"children":889},{"__ignoreMap":7},[890,898,906,914,922,930],{"type":16,"tag":69,"props":891,"children":892},{"class":71,"line":72},[893],{"type":16,"tag":69,"props":894,"children":895},{},[896],{"type":21,"value":897},"Get-ChildItem \"$env:USERPROFILE\\.claude\\sessions\\*.json\" | ForEach-Object {\n",{"type":16,"tag":69,"props":899,"children":900},{"class":71,"line":93},[901],{"type":16,"tag":69,"props":902,"children":903},{},[904],{"type":21,"value":905},"  $s = Get-Content $_ -Raw | ConvertFrom-Json\n",{"type":16,"tag":69,"props":907,"children":908},{"class":71,"line":164},[909],{"type":16,"tag":69,"props":910,"children":911},{},[912],{"type":21,"value":913},"  if (Get-Process -Id $s.pid -ErrorAction SilentlyContinue) {\n",{"type":16,"tag":69,"props":915,"children":916},{"class":71,"line":186},[917],{"type":16,"tag":69,"props":918,"children":919},{},[920],{"type":21,"value":921},"    \"{0}`t{1}`t{2}`t{3}\" -f $s.pid, $s.status, $s.name, $s.cwd\n",{"type":16,"tag":69,"props":923,"children":924},{"class":71,"line":208},[925],{"type":16,"tag":69,"props":926,"children":927},{},[928],{"type":21,"value":929},"  }\n",{"type":16,"tag":69,"props":931,"children":932},{"class":71,"line":230},[933],{"type":16,"tag":69,"props":934,"children":935},{},[936],{"type":21,"value":430},{"type":16,"tag":17,"props":938,"children":939},{},[940,942,947,949,955],{"type":21,"value":941},"That is enough for anything interactive. If you want to be strict about it, there is a second failure mode: process ids get reused, so a dead session's number can come back attached to something else entirely. ",{"type":16,"tag":50,"props":943,"children":945},{"className":944},[],[946],{"type":21,"value":596},{"type":21,"value":948}," is the guard. On Linux it is the process start time in clock ticks, the same value as field 22 of ",{"type":16,"tag":50,"props":950,"children":952},{"className":951},[],[953],{"type":21,"value":954},"/proc/<pid>/stat",{"type":21,"value":956},":",{"type":16,"tag":59,"props":958,"children":960},{"code":959,"language":62,"meta":7,"className":63,"style":7},"$ jq -r .procStart ~/.claude/sessions/1324.json\n2277\n$ awk '{print $22}' /proc/1324/stat\n2277\n",[961],{"type":16,"tag":50,"props":962,"children":963},{"__ignoreMap":7},[964,990,998,1020],{"type":16,"tag":69,"props":965,"children":966},{"class":71,"line":72},[967,971,976,980,985],{"type":16,"tag":69,"props":968,"children":969},{"style":76},[970],{"type":21,"value":79},{"type":16,"tag":69,"props":972,"children":973},{"style":82},[974],{"type":21,"value":975}," jq",{"type":16,"tag":69,"props":977,"children":978},{"style":143},[979],{"type":21,"value":743},{"type":16,"tag":69,"props":981,"children":982},{"style":82},[983],{"type":21,"value":984}," .procStart",{"type":16,"tag":69,"props":986,"children":987},{"style":82},[988],{"type":21,"value":989}," ~/.claude/sessions/1324.json\n",{"type":16,"tag":69,"props":991,"children":992},{"class":71,"line":93},[993],{"type":16,"tag":69,"props":994,"children":995},{"style":76},[996],{"type":21,"value":997},"2277\n",{"type":16,"tag":69,"props":999,"children":1000},{"class":71,"line":164},[1001,1005,1010,1015],{"type":16,"tag":69,"props":1002,"children":1003},{"style":76},[1004],{"type":21,"value":79},{"type":16,"tag":69,"props":1006,"children":1007},{"style":82},[1008],{"type":21,"value":1009}," awk",{"type":16,"tag":69,"props":1011,"children":1012},{"style":82},[1013],{"type":21,"value":1014}," '{print $22}'",{"type":16,"tag":69,"props":1016,"children":1017},{"style":82},[1018],{"type":21,"value":1019}," /proc/1324/stat\n",{"type":16,"tag":69,"props":1021,"children":1022},{"class":71,"line":186},[1023],{"type":16,"tag":69,"props":1024,"children":1025},{"style":76},[1026],{"type":21,"value":997},{"type":16,"tag":17,"props":1028,"children":1029},{},[1030,1032,1038],{"type":21,"value":1031},"Compare the two and a recycled pid stops looking live. In practice you also want to confirm the process really is a ",{"type":16,"tag":50,"props":1033,"children":1035},{"className":1034},[],[1036],{"type":21,"value":1037},"claude",{"type":21,"value":1039},", which the same check gives you for free.",{"type":16,"tag":38,"props":1041,"children":1043},{"id":1042},"why-the-cwd-is-the-interesting-part",[1044],{"type":21,"value":1045},"Why the cwd is the interesting part",{"type":16,"tag":17,"props":1047,"children":1048},{},[1049],{"type":21,"value":1050},"Every other field you could get some other way. The working directory you mostly cannot.",{"type":16,"tag":17,"props":1052,"children":1053},{},[1054,1056,1062,1064,1070],{"type":21,"value":1055},"On Linux and inside WSL it is a ",{"type":16,"tag":50,"props":1057,"children":1059},{"className":1058},[],[1060],{"type":21,"value":1061},"readlink /proc/<pid>/cwd",{"type":21,"value":1063},". On macOS you can get there with ",{"type":16,"tag":50,"props":1065,"children":1067},{"className":1066},[],[1068],{"type":21,"value":1069},"lsof -a -p <pid> -d cwd -Fn",{"type":21,"value":1071},". On Windows there is no supported way at all: the value lives in the process environment block, and reading another process's PEB means opening it with memory-read rights and walking undocumented structures, which is the sort of thing that makes security software take an interest in your program.",{"type":16,"tag":17,"props":1073,"children":1074},{},[1075],{"type":21,"value":1076},"A JSON file the application wrote itself is a considerably better idea than any of that.",{"type":16,"tag":38,"props":1078,"children":1080},{"id":1079},"treat-it-as-a-convenience-not-an-api",[1081],{"type":21,"value":1082},"Treat it as a convenience, not an API",{"type":16,"tag":17,"props":1084,"children":1085},{},[1086],{"type":21,"value":1087},"This is internal state, not a published interface. The file above came from version 2.1.261; the shape can change in any release, and nothing promises it will still be there next month.",{"type":16,"tag":17,"props":1089,"children":1090},{},[1091],{"type":21,"value":1092},"That is fine for what it is good at. Read it best-effort, tolerate missing fields, and make sure your script still does something sensible when the directory is empty or the JSON has grown a key you have never seen. What you should not do is build something that stops working the day the format moves.",{"type":16,"tag":38,"props":1094,"children":1096},{"id":1095},"knowing-what-is-running-without-a-script",[1097],{"type":21,"value":1098},"Knowing what is running, without a script",{"type":16,"tag":17,"props":1100,"children":1101},{},[1102],{"type":21,"value":1103},"The reason to want any of this is usually the same: several sessions going at once, and no quick way to see which is which. A registry read gets you a list in a terminal.",{"type":16,"tag":17,"props":1105,"children":1106},{},[1107,1113],{"type":16,"tag":24,"props":1108,"children":1110},{"href":1109},"/",[1111],{"type":21,"value":1112},"Blooby",{"type":21,"value":1114}," answers it without the terminal. It gives every project its own animated mascot on your desktop, so a glance tells you which session is working, which one is waiting on you and which one has finished. It reads the same ground truth this guide describes, for the same reason: hooks tell you what just happened, and the process tree tells you what is actually there.",{"type":16,"tag":1116,"props":1117,"children":1118},"style",{},[1119],{"type":21,"value":1120},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":7,"searchDepth":93,"depth":93,"links":1122},[1123,1124,1125,1126,1127,1128],{"id":40,"depth":93,"text":43},{"id":604,"depth":93,"text":607},{"id":649,"depth":93,"text":652},{"id":1042,"depth":93,"text":1045},{"id":1079,"depth":93,"text":1082},{"id":1095,"depth":93,"text":1098},"markdown","content:guides:claude-code-sessions-registry.md","content","guides/claude-code-sessions-registry.md","guides/claude-code-sessions-registry","md",1]