[{"data":1,"prerenderedAt":1122,"buildId":1123},["ShallowReactive",2],{"docs:\u002Fguide\u002Freaders":3},{"page":4,"section":16,"document":17,"credits":10,"prev":1116,"next":1120},{"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},"readers","\u002Fguide\u002Freaders","guide\u002Freaders.md","Readers","How readerly decides whether a coding agent, CI, a person at a terminal or a pipe reads a command's output, step by step, and how to override it.",null,[],"i-lucide-scan-eye","article",true,3,"guide",{"nodes":18,"toc":1098},[19,28,90,110,118,131,368,374,382,447,477,487,579,724,747,756,785,794,804,823,837,843,856,1063,1091],[20,21,22,23,27],"p",{},"readerly sorts every run into one of four readers. This page lists the checks that decide which one, in order, and the fields ",[24,25,26],"code",{},"detect()"," returns.",[29,30,31,46],"table",{},[32,33,34],"thead",{},[35,36,37,43],"tr",{},[38,39,40],"th",{},[24,41,42],{},"Reader",[38,44,45],{},"Who reads the output",[47,48,49,60,70,80],"tbody",{},[35,50,51,57],{},[52,53,54],"td",{},[24,55,56],{},"agent",[52,58,59],{},"A coding agent such as Claude Code, Codex or Gemini CLI",[35,61,62,67],{},[52,63,64],{},[24,65,66],{},"ci",[52,68,69],{},"A CI job, such as GitHub Actions or GitLab CI",[35,71,72,77],{},[52,73,74],{},[24,75,76],{},"terminal",[52,78,79],{},"A person at a terminal",[35,81,82,87],{},[52,83,84],{},[24,85,86],{},"pipe",[52,88,89],{},"Another program, a file or a pipe",[20,91,92,93,95,96,99,100,103,104,109],{},"A program that asks for JSON is a fifth reader in practice, but not a fifth ",[24,94,42],{}," value. It passes ",[24,97,98],{},"--format json"," or ",[24,101,102],{},"--json",", which picks the ",[105,106,108],"a",{"href":107},"\u002Fguide\u002Fformats","format",". Detection still runs.",[111,112,117],"h2",{"id":113,"anchor":114},"detection-order",{"label":115,"icon":116},"Section titled \"Detection order\"","#","Detection order",[20,119,120,122,123,126,127,130],{},[24,121,26],{}," checks these in order and stops at the first match. The ",[24,124,125],{},"reason"," column is the string it puts in ",[24,128,129],{},"Detection.reason",".",[132,133,134,181,233,269,295,332,350],"steps",{},[135,136,138,145],"step",{"index":137},"1",[139,140,144],"h3",{"id":141,"anchor":142},"caller-override",{"label":143,"icon":116},"Section titled \"Caller override\"","Caller override",[20,146,147,150,151,153,154,157,158,160,161,99,163,165,166,168,169,172,173,176,177,180],{},[24,148,149],{},"detect({ agent: true })"," makes the reader ",[24,152,56],{},". ",[24,155,156],{},"detect({ agent: false })"," rules an agent out and picks ",[24,159,66],{},", ",[24,162,76],{},[24,164,86],{}," as steps 4, 6 and 7 do. Either way ",[24,167,125],{}," is ",[24,170,171],{},"override",". With ",[24,174,175],{},"agent: true",", the agent details come only from signals the steps below would trust: a declared ",[24,178,179],{},"AI_AGENT",", a strong marker, or a weak marker off a TTY and outside CI.",[135,182,184,191,217],{"index":183},"2",[139,185,189],{"id":186,"anchor":187},"ai_agent",{"label":188,"icon":116},"Section titled \"AI_AGENT\"",[24,190,179],{},[20,192,193,194,196,197,199,200,168,202,204,205,160,208,211,212,216],{},"When ",[24,195,179],{}," is set to any value other than an opt-out, the reader is ",[24,198,56],{}," and ",[24,201,125],{},[24,203,179],{},". The value names the agent: ",[24,206,207],{},"claude-code",[24,209,210],{},"codex_0-172-0_agent",", or your own name. ",[105,213,215],{"href":214},"\u002Fguide\u002Fagents#declaring-an-agent","Coding agents"," has the parsing rules.",[20,218,219,220,160,223,160,226,160,229,232],{},"The opt-out values are ",[24,221,222],{},"0",[24,224,225],{},"false",[24,227,228],{},"no",[24,230,231],{},"off"," and the empty string, trimmed and in any case. They skip every marker in steps 3 and 5, so the run goes straight to CI, terminal or pipe.",[135,234,236,242],{"index":235},"3",[139,237,241],{"id":238,"anchor":239},"strong-markers",{"label":240,"icon":116},"Section titled \"Strong markers\"","Strong markers",[20,243,244,245,160,248,99,251,254,255,257,258,260,261,264,265,268],{},"A strong marker is a variable a harness sets only while a model runs the command, such as ",[24,246,247],{},"CLAUDECODE",[24,249,250],{},"CODEX_THREAD_ID",[24,252,253],{},"GEMINI_CLI",". A match makes the reader ",[24,256,56],{}," with ",[24,259,125],{}," ",[24,262,263],{},"marker:\u003CNAME>",", such as ",[24,266,267],{},"marker:CODEX_THREAD_ID",". Strong markers win in CI and in a real TTY: Gemini CLI and Cline run commands in a TTY, and their output still goes to an agent.",[135,270,272,277],{"index":271},"4",[139,273,276],{"id":66,"anchor":274},{"label":275,"icon":116},"Section titled \"CI\"","CI",[20,278,279,280,150,284,286,287,260,289,264,292,130],{},"A CI variable from the ",[105,281,283],{"href":282},"#ci-providers","table below",[24,285,66],{},", with ",[24,288,125],{},[24,290,291],{},"CI:\u003Cname>",[24,293,294],{},"CI:github-actions",[135,296,298,304,318],{"index":297},"5",[139,299,303],{"id":300,"anchor":301},"weak-markers",{"label":302,"icon":116},"Section titled \"Weak markers\"","Weak markers",[20,305,306,307,310,311,257,313,260,315,130],{},"A weak marker can also sit in a person's shell. ",[24,308,309],{},"CURSOR_TRACE_ID"," is set in a person's Cursor terminal as well as in Cursor's agent. readerly counts a weak marker only when stdout is not a TTY, and step 4 has already ruled out CI. A match makes the reader ",[24,312,56],{},[24,314,125],{},[24,316,317],{},"weak:\u003CNAME>",[20,319,320,321,324,325,328,329,130],{},"A bare ",[24,322,323],{},"AGENT"," variable is a weak marker too. When its value is a known harness id, such as ",[24,326,327],{},"AGENT=goose",", it names that harness; otherwise the agent id is ",[24,330,331],{},"unknown",[135,333,335,340],{"index":334},"6",[139,336,339],{"id":76,"anchor":337},{"label":338,"icon":116},"Section titled \"Terminal\"","Terminal",[20,341,342,343,199,345,168,347,130],{},"When stdout is a TTY, the reader is ",[24,344,76],{},[24,346,125],{},[24,348,349],{},"stdout.isTTY",[135,351,353,358],{"index":352},"7",[139,354,357],{"id":86,"anchor":355},{"label":356,"icon":116},"Section titled \"Pipe\"","Pipe",[20,359,360,361,286,363,260,365,130],{},"Everything else is ",[24,362,86],{},[24,364,125],{},[24,366,367],{},"stdout not a TTY",[20,369,370,371,130],{},"Strong markers are checked for every known harness before any weak marker. That is how Codex running inside a Cursor terminal is reported as Codex and not Cursor. The markers for each harness are in ",[105,372,215],{"href":373},"\u002Fguide\u002Fagents#known-harnesses",[111,375,379,380],{"id":376,"anchor":377},"calling-detect",{"label":378,"icon":116},"Section titled \"Calling detect()\"","Calling ",[24,381,26],{},[383,384,388],"pre",{"language":385,"filename":386,"class":387,"wrap":14},"ts","who.ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[24,389,391,414,415,414,417,414,436],{"class":390},"language-ts",[392,393,396,400,404,407,411],"span",{"class":394,"style":395},"line","display: inline",[392,397,399],{"style":398},"color:#CF222E;--shiki-dark:#FF7B72","import",[392,401,403],{"style":402},"color:#1F2328;--shiki-dark:#E6EDF3"," { detect } ",[392,405,406],{"style":398},"from",[392,408,410],{"style":409},"color:#0A3069;--shiki-dark:#A5D6FF"," \"readerly\u002Fdetect\"",[392,412,413],{"style":402},";","\n",[392,416],{"class":394,"style":395},[392,418,419,422,426,429,433],{"class":394,"style":395},[392,420,421],{"style":398},"const",[392,423,425],{"style":424},"color:#0550AE;--shiki-dark:#79C0FF"," detection",[392,427,428],{"style":398}," =",[392,430,432],{"style":431},"color:#8250DF;--shiki-dark:#D2A8FF"," detect",[392,434,435],{"style":402},"();",[392,437,438,441,444],{"class":394,"style":395},[392,439,440],{"style":402},"console.",[392,442,443],{"style":431},"log",[392,445,446],{"style":402},"(detection.reader, detection.reason);",[20,448,449,451,452,455,456,160,459,199,462,465,466,160,469,160,472,99,474,476],{},[24,450,26],{}," is synchronous and writes nothing. It reads ",[24,453,454],{},"process.env"," and the TTY state of ",[24,457,458],{},"process.stdout",[24,460,461],{},"stderr",[24,463,464],{},"stdin"," on every call, never at import, so a process that changes its env between runs gets a fresh answer. Pass ",[24,467,468],{},"env",[24,470,471],{},"stdout",[24,473,461],{},[24,475,464],{}," to read those instead of the real process.",[20,478,479,480,483,484,486],{},"Under ",[24,481,482],{},"AI_AGENT=claude-code",", with stdout piped, ",[24,485,26],{}," returns:",[383,488,490],{"language":489,"class":387,"wrap":14},"text",[24,491,493,414,498,414,503,414,508,414,513,414,518,414,523,414,528,414,533,414,538,414,543,414,547,414,552,414,556,414,560,414,565,414,569,414,574],{"class":492},"language-text",[392,494,495],{"class":394,"style":395},[392,496,497],{},"{",[392,499,500],{"class":394,"style":395},[392,501,502],{},"  \"reader\": \"agent\",",[392,504,505],{"class":394,"style":395},[392,506,507],{},"  \"reason\": \"AI_AGENT\",",[392,509,510],{"class":394,"style":395},[392,511,512],{},"  \"agent\": {",[392,514,515],{"class":394,"style":395},[392,516,517],{},"    \"id\": \"claude-code\",",[392,519,520],{"class":394,"style":395},[392,521,522],{},"    \"raw\": \"claude-code\",",[392,524,525],{"class":394,"style":395},[392,526,527],{},"    \"strength\": \"declared\"",[392,529,530],{"class":394,"style":395},[392,531,532],{},"  },",[392,534,535],{"class":394,"style":395},[392,536,537],{},"  \"stdout\": {",[392,539,540],{"class":394,"style":395},[392,541,542],{},"    \"isTTY\": false",[392,544,545],{"class":394,"style":395},[392,546,532],{},[392,548,549],{"class":394,"style":395},[392,550,551],{},"  \"stderr\": {",[392,553,554],{"class":394,"style":395},[392,555,542],{},[392,557,558],{"class":394,"style":395},[392,559,532],{},[392,561,562],{"class":394,"style":395},[392,563,564],{},"  \"stdin\": {",[392,566,567],{"class":394,"style":395},[392,568,542],{},[392,570,571],{"class":394,"style":395},[392,572,573],{},"  }",[392,575,576],{"class":394,"style":395},[392,577,578],{},"}",[29,580,581,594],{},[32,582,583],{},[35,584,585,591],{},[38,586,587,590],{},[24,588,589],{},"Detection"," field",[38,592,593],{},"What it holds",[47,595,596,613,639,678,692,703,714],{},[35,597,598,603],{},[52,599,600],{},[24,601,602],{},"reader",[52,604,605,160,607,160,609,99,611],{},[24,606,56],{},[24,608,66],{},[24,610,76],{},[24,612,86],{},[35,614,615,619],{},[52,616,617],{},[24,618,125],{},[52,620,621,622,624,625,160,627,160,629,160,631,160,633,160,635,99,637],{},"The signal that decided ",[24,623,602],{},": ",[24,626,171],{},[24,628,179],{},[24,630,263],{},[24,632,317],{},[24,634,291],{},[24,636,349],{},[24,638,367],{},[35,640,641,645],{},[52,642,643],{},[24,644,56],{},[52,646,647,648,651,652,160,655,658,659,160,662,160,665,160,668,160,671,199,674,677],{},"An ",[24,649,650],{},"AgentInfo"," when an agent was found: ",[24,653,654],{},"id",[24,656,657],{},"strength",", and ",[24,660,661],{},"raw",[24,663,664],{},"version",[24,666,667],{},"mode",[24,669,670],{},"sessionId",[24,672,673],{},"effort",[24,675,676],{},"wrapper"," when known",[35,679,680,684],{},[52,681,682],{},[24,683,66],{},[52,685,686,689,690],{},[24,687,688],{},"{ name }"," when a CI variable is set, even when the reader is ",[24,691,56],{},[35,693,694,698],{},[52,695,696],{},[24,697,471],{},[52,699,700],{},[24,701,702],{},"{ isTTY, columns? }",[35,704,705,709],{},[52,706,707],{},[24,708,461],{},[52,710,711],{},[24,712,713],{},"{ isTTY }",[35,715,716,720],{},[52,717,718],{},[24,719,464],{},[52,721,722],{},[24,723,713],{},[20,725,726,729,730,732,733,736,737,740,741,99,743,746],{},[24,727,728],{},"createOut"," calls ",[24,731,26],{}," with its ",[24,734,735],{},"io",". Pass ",[24,738,739],{},"detection"," to ",[24,742,728],{},[24,744,745],{},"resolveProfile"," to use your own and skip detection, as tests do.",[111,748,752,755],{"id":749,"anchor":750},"format-never-skips-detection",{"label":751,"icon":116},"Section titled \"--format never skips detection\"",[24,753,754],{},"--format"," never skips detection",[20,757,758,160,760,199,762,765,766,769,770,772,773,168,776,778,779,658,781,784],{},[24,759,754],{},[24,761,102],{},[24,763,764],{},"\u003CTOOL>_FORMAT"," pick the format, but readerly still detects the reader. Under Gemini CLI in a real TTY, ",[24,767,768],{},"acme check --format text"," prints ",[24,771,489],{},", yet ",[24,774,775],{},"profile.interactive",[24,777,225],{}," because the reader is ",[24,780,56],{},[24,782,783],{},"profile.budget"," stays at 8,000 characters. An agent's shell never gets a prompt it can't answer.",[111,786,790,791],{"id":787,"anchor":788},"opting-out-with-ai_agent0",{"label":789,"icon":116},"Section titled \"Opting out with AI_AGENT=0\"","Opting out with ",[24,792,793],{},"AI_AGENT=0",[20,795,796,797,800,801,803],{},"An agent can leave its variables in a shell a person later uses, such as a tmux session the agent opened. ",[24,798,799],{},"CLAUDECODE=1"," is still set there, and every command would print for an agent. Set ",[24,802,793],{}," in that shell:",[383,805,807],{"language":806,"frame":76,"class":387,"wrap":14},"sh",[24,808,810],{"class":809},"language-sh",[392,811,812,815,818,821],{"class":394,"style":395},[392,813,814],{"style":398},"export",[392,816,817],{"style":402}," AI_AGENT",[392,819,820],{"style":398},"=",[392,822,222],{"style":424},[20,824,825,826,199,828,830,831,257,833,260,835,130],{},"With ",[24,827,793],{},[24,829,799],{}," in a TTY, the reader is ",[24,832,76],{},[24,834,125],{},[24,836,349],{},[111,838,842],{"id":839,"anchor":840},"ci-providers",{"label":841,"icon":116},"Section titled \"CI providers\"","CI providers",[20,844,845,848,849,855],{},[24,846,847],{},"ciName(env)"," in ",[105,850,852],{"href":851},"https:\u002F\u002Fgithub.com\u002Floadsheet\u002Freaderly\u002Fblob\u002Fmain\u002Fsrc\u002Fci.ts",[24,853,854],{},"src\u002Fci.ts"," checks these in order. A bare-name variable counts when it is set and not an opt-out value.",[29,857,858,870],{},[32,859,860],{},[35,861,862,867],{},[38,863,864],{},[24,865,866],{},"ci.name",[38,868,869],{},"Variable",[47,871,872,884,896,908,920,932,944,956,968,980,992,1004,1016,1028,1040,1052],{},[35,873,874,879],{},[52,875,876],{},[24,877,878],{},"github-actions",[52,880,881],{},[24,882,883],{},"GITHUB_ACTIONS",[35,885,886,891],{},[52,887,888],{},[24,889,890],{},"gitlab",[52,892,893],{},[24,894,895],{},"GITLAB_CI",[35,897,898,903],{},[52,899,900],{},[24,901,902],{},"circleci",[52,904,905],{},[24,906,907],{},"CIRCLECI",[35,909,910,915],{},[52,911,912],{},[24,913,914],{},"travis",[52,916,917],{},[24,918,919],{},"TRAVIS",[35,921,922,927],{},[52,923,924],{},[24,925,926],{},"buildkite",[52,928,929],{},[24,930,931],{},"BUILDKITE",[35,933,934,939],{},[52,935,936],{},[24,937,938],{},"azure-pipelines",[52,940,941],{},[24,942,943],{},"TF_BUILD",[35,945,946,951],{},[52,947,948],{},[24,949,950],{},"bitbucket",[52,952,953],{},[24,954,955],{},"BITBUCKET_BUILD_NUMBER",[35,957,958,963],{},[52,959,960],{},[24,961,962],{},"jenkins",[52,964,965],{},[24,966,967],{},"JENKINS_URL",[35,969,970,975],{},[52,971,972],{},[24,973,974],{},"teamcity",[52,976,977],{},[24,978,979],{},"TEAMCITY_VERSION",[35,981,982,987],{},[52,983,984],{},[24,985,986],{},"drone",[52,988,989],{},[24,990,991],{},"DRONE",[35,993,994,999],{},[52,995,996],{},[24,997,998],{},"woodpecker",[52,1000,1001],{},[24,1002,1003],{},"CI=woodpecker",[35,1005,1006,1011],{},[52,1007,1008],{},[24,1009,1010],{},"appveyor",[52,1012,1013],{},[24,1014,1015],{},"APPVEYOR",[35,1017,1018,1023],{},[52,1019,1020],{},[24,1021,1022],{},"vercel",[52,1024,1025],{},[24,1026,1027],{},"VERCEL",[35,1029,1030,1035],{},[52,1031,1032],{},[24,1033,1034],{},"netlify",[52,1036,1037],{},[24,1038,1039],{},"NETLIFY",[35,1041,1042,1047],{},[52,1043,1044],{},[24,1045,1046],{},"cloudflare-pages",[52,1048,1049],{},[24,1050,1051],{},"CF_PAGES",[35,1053,1054,1059],{},[52,1055,1056],{},[24,1057,1058],{},"generic",[52,1060,1061],{},[24,1062,276],{},[20,1064,1065,160,1068,160,1070,99,1072,1074,1075,1077,1078,1081,1082,1084,1085,740,1089,130],{},[24,1066,1067],{},"CI=0",[24,1069,225],{},[24,1071,228],{},[24,1073,231],{}," turns CI detection off, even with ",[24,1076,883],{}," set. ",[24,1079,1080],{},"CODEX_CI"," is a Codex marker, not CI. Only ",[24,1083,878],{}," changes the output: it adds ",[105,1086,1088],{"href":1087},"\u002Fintegrations\u002Fgithub-actions","annotations",[24,1090,489],{},[20,1092,1093,1094,1097],{},"Next: ",[105,1095,215],{"href":1096},"\u002Fguide\u002Fagents"," covers what an agent gets once it is detected.",[1099,1109,1111,1113,1115],{"id":113,"depth":1100,"text":117,"children":1101},2,[1102,1103,1104,1105,1106,1107,1108],{"id":141,"depth":15,"text":144},{"id":186,"depth":15,"text":179},{"id":238,"depth":15,"text":241},{"id":66,"depth":15,"text":276},{"id":300,"depth":15,"text":303},{"id":76,"depth":15,"text":339},{"id":86,"depth":15,"text":357},{"id":376,"depth":1100,"text":1110},"Calling detect()",{"id":749,"depth":1100,"text":1112},"--format never skips detection",{"id":787,"depth":1100,"text":1114},"Opting out with AI_AGENT=0",{"id":839,"depth":1100,"text":842},{"path":1117,"title":1118,"description":1119},"\u002Fguide\u002Finstallation","Installation","Install readerly, wrap one command with createOut, and run it as a person, as a coding agent and as a JSON consumer to see each output.",{"path":1096,"title":215,"description":1121},"What a coding agent gets from a readerly command, which harnesses readerly knows by their env vars, and how a tool declares itself with AI_AGENT.",1795985392465,"22ea5d7b-bce0-4e3b-bca3-1fbe3722fcf7"]