Skip to content

Install the skill where agents read it, add string skill, and rewrite the skill for 0.3 - #63

Merged
asavor merged 45 commits into
mainfrom
skill-dirs
Nov 21, 2026
Merged

asavor merged 45 commits into
mainfrom
skill-dirs

Conversation

@asavor

@asavor asavor commented Nov 20, 2026

Copy link
Copy Markdown
Collaborator

Why

string init put the skill in every agent's directory it found, five or more on a typical machine. Gemini CLI reads both ~/.gemini/skills and ~/.agents/skills, so it found the skill twice and warned "Skill conflict detected" at every start. Most agents read ~/.agents/skills now, and Claude Code reads ~/.claude/skills, so two copies reach nearly all of them.

The skill itself still taught 0.2: --json on fetch for JSON errors, unbounded waits, no way to keep a big page out of context. At 213 lines it also cost about 3.3k tokens in every session that loaded it. And an agent couldn't read it without installing it first.

Summary

Stacked on usestring/cli "Keep a page from taking over a person's terminal, and refuse binary there" (#62). Merge #42 to #62 in order first, then this. This is the last step of 0.3's agent-facing changes.

  • init puts the skill in these places:

    • always in ~/.agents/skills, which Codex, Cursor, Gemini CLI, OpenCode, GitHub Copilot, Goose, Droid and others read. init names the agents it found that read it there.
    • in ~/.claude/skills when Claude Code is on the machine, under $CLAUDE_CONFIG_DIR when that is set.
    • in an agent's own directory, only for agents found here that read neither: Windsurf, Kiro CLI, Qwen Code, Grok Build, OpenClaw and Hermes Agent.
    • --agent NAME still writes exactly the agents it names, each in its own directory, and touches nothing else. That covers an agent version too old to read ~/.agents/skills.
  • Without --agent, init removes Gemini CLI's duplicate, ~/.gemini/skills/string-cli, and says so. It removes only a plain copy as init wrote it: a directory, not a link, holding just a SKILL.md whose frontmatter names string-cli. A link, extra files or another skill's name stay as they are, and init says why. An empty folder is left without a word. The rest of ~/.gemini/skills is never touched.

  • Older copies elsewhere, such as ~/.cursor/skills/string-cli, stay. A new release's first command still refreshes every copy, as before.

  • string skill prints the SKILL.md this release carries, so an agent can read it, or save it anywhere, without installing anything. string skill --path lists the installed copies, one path per line, and says on stderr when there are none.

  • The skill is rewritten for 0.3, in 149 lines, down from 213 (about 2.6k tokens, down from 3.3k). Its description now says when to reach for string: a page or search that curl or WebFetch can't read (blocked, empty, JavaScript-only), a crawl, or structured site data. It teaches:

    • --errors json, not --json, on fetch;
    • -o with the outline, then sed -n on one section;
    • --max-tokens parts, read from the local copy;
    • exit 7 as "run the next command", for --poll and --wait;
    • whoami's check;
    • the next_commands types, and which steps an agent takes alone;
    • the 0.3 exit codes, and the help topics.

    The string trial lines stay as the fallback for when nobody can approve a key. The 409 partial_state advice stays, since the CLI doesn't handle that case itself.

  • The help for init and for all of string, string help agents and the README say all of this.

Risks

  • An agent version that reads only its own directory, and not ~/.agents/skills, gets no new copy on a fresh machine. string init --agent NAME writes its directory, and the removal line says so for Gemini CLI.
  • A user who edited the skill in ~/.gemini/skills without adding a file loses the edit. init prints the path it removed.
  • The skills catalog in usestring/skills carries its own copy of this file for the plugins. A matching PR there is to follow, to merge with this release.

Tradeoffs

  • Which agents read ~/.agents/skills comes from their documentation and source as of this month, not from running each one.
  • The skill is still hand-written. The command table that would generate its command and flag sections, and the skill's allowed-tools, come later in the plan.
  • string skill --path lists the copies in the directories init knows. A copy that a skills installer put somewhere else isn't listed.

Test plan

  • go vet ./... and go test ./... pass on Go 1.27.4 and Go 1.25.0; go vet also passes cross-compiled for Windows, macOS and FreeBSD.
  • TestInitPutsTheSkillWhereEachAgentReadsIt checks init's exact output on a machine with Claude Code, Cursor, Windsurf, and Gemini CLI holding an older copy plus a skill of the user's own. It also checks:
    • the files written to ~/.agents/skills, ~/.claude/skills and Windsurf's directory;
    • no copy for Cursor;
    • the older Gemini copy gone, and the user's own skill still there;
    • nothing more to remove on a second run.
  • TestInitLeavesAGeminiCopyItDidntWrite checks that init leaves a Gemini copy, with the exact line, when it has an extra file, has another skill's name or is a link. It also checks:
    • an empty folder left without a word;
    • --agent codex leaving the copy alone;
    • --agent gemini-cli,cursor writing those two directories only.
  • TestSkillPrintsTheGuideAndWhereItIsInstalled checks:
    • string skill against the embedded file;
    • --path with no copies, with -q, with a directory two agents share, and with a folder that has no SKILL.md;
    • the usage errors, and string skills naming string skill.
  • TestTheSkillTeachesOnlyWhatStringHas keeps the skill at 150 lines or fewer, with a valid frontmatter. It fails on any string COMMAND that isn't a command, and on any flag that no help page has.
  • TestLoginHelpKeepsTheFlagsTheHostedGuideLooksFor checks that string login --help still lists --browser, --no-wait, --env-file and --poll. String's hosted onboarding guide looks for them.
  • Each of 21 mutations fails a test, among them:
    • shared agents given their own copy;
    • no removal, or removal with --agent;
    • links followed, extra files allowed, or the name not checked;
    • --path listing a folder without SKILL.md;
    • the refresh skipping copies;
    • an undocumented flag, an unknown command, or a 151st line in the skill.
  • CI on Linux, macOS and Windows.

Generated with Claude Code

asavor and others added 30 commits November 20, 2026 00:43
main now builds one execCtx before the command runs: which of stdin,
stdout and stderr are terminals, whether a coding agent runs string, and
whether it is a CI job. The two terminal flags the runtime carried become
its stdinTTY and stderrTTY, with no change in behavior.

The agent is named from the variables only an agent's command runner
sets, in a fixed order: STRING_AGENT, which can also force the person's
view; AI_AGENT, cut to its name; the runners' own variables; CLAUDECODE
or CLAUDE_CODE_ENTRYPOINT only when stdin is not a terminal, since IDE
terminals set them for people too; then AGENT. TERM, TERM_PROGRAM and
the process tree are never read.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An update notice used to show whenever stderr was a terminal. Coding
agents can run string in a pseudo-terminal, so the notice landed in
what the agent read. Now it shows only when stdout and stderr are both
terminals, no coding agent runs string, and it isn't a CI job. A copy
that only gets notices is checked for a release under the same rule.

A copy the install script installed still updates itself in the
background as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The help says that string finds a coding agent from the variables agents
set and then shows no update notices, and how STRING_AGENT names the
agent or a person. The README gets a Coding agents section with the
variables string reads and what changes under an agent, and the Updating
section says notices are for a person at a terminal.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Requests to String's API, portal and sign-in service now carry a
User-Agent of string-cli/<version> (<os>/<arch>), with "; agent=<name>"
when a coding agent runs string, in place of Go's default. They also
carry X-String-CLI-Mode (interactive, agent, non-interactive or ci),
X-String-Agent with the agent's name, and X-String-Agent-Raw with
AI_AGENT as the agent set it. String can then tell people, scripts, CI
and each agent apart in its own request logs. string sends nothing
else, and no events of its own.

DO_NOT_TRACK=1 sends only string-cli/<version> and none of the
X-String headers.

The download host keeps its own User-Agent, as the README promises.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The help now says that requests to String carry string's version, the
system and the agent's name, and that DO_NOT_TRACK=1 sends only the
version. The README's Coding agents section lists each header, what it
carries and what DO_NOT_TRACK leaves out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Update checks and downloads now carry userAgent(): string-cli/<version>
(<os>/<arch>), with the agent's name under a coding agent, and only
string-cli/<version> under DO_NOT_TRACK, so the two can't drift apart.
They still send none of the X-String headers, which the download host
doesn't read. The README's Updating section says what the host gets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login and init started the system's browser opener on every sign-in:
under a coding agent, in CI, with stdout piped and with --json. Now they
open the link only when execCtx says a person is at a terminal (stdin and
stdout terminals, no agent, no CI), and --no-open, anywhere before --,
stops it there too. What they print is unchanged.

One function now takes --json and --no-open out of the arguments, and
afterCommand uses it too, so a switch before the command name doesn't
hide the command from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login, init and trial claim waited for an approval whenever stdin was a
terminal, so a coding agent running string in a pseudo-terminal, or a CI
job with one, blocked until the code expired. They now wait only when
execCtx says a person is at the terminal: stdin and stdout terminals, no
agent, no CI and no --no-input. Anywhere else they print the link and
code and return, and only --poll waits.

--no-input, or STRING_NO_INPUT=1, says nobody will answer, for scripts
and anyone else. -y and --yes are taken by every command, to confirm
what it would ask first; none asks yet. trial claim without --email now
names the flag, with exit 2 and the code missing_input.

The sign-in test fixture builds its execCtx from its variables, as main
does, so a test sets CI, an agent or STRING_NO_INPUT there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
afterCommand finds the command after the global switches, as run()
does, so string --no-open update and string -y update start no update
check. The test now covers both, so the two can't drift apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request that never answered held string for five minutes, and an
answer that stalled halfway held it for good. Under a coding agent that
runs past the two minutes some agents allow a command, and the agent
stops string without an error to read.

Each request to String now has a time limit: 120s, 300s for an
integration's action, and 90s for any request under an agent.
--timeout DURATION sets another, as 90s, 5m or seconds, or 0 for none,
anywhere before --. An answer that sends nothing for 60s ends too.
Either exits 7 with code timeout, and the error offers twice the limit,
to run in the background where an agent's shell stops commands at two
minutes.

The client no longer stops at five minutes without response headers;
the request's own limit does that now. Downloads keep their deadlines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sitemap --wait polled until the crawl ended: in silence unless stderr was
a terminal, and forever on a status it didn't know. Under a coding agent
a crawl outlasts the two minutes some agents give a command, so the agent
stopped string with no word of the job or how to pick it up.

--wait now first prints the job and the command that resumes the wait.
A person who sees stderr at a terminal still gets one progress line
redrawn in place; anywhere else, an agent's terminal included, a plain
line comes every 15s. Under an agent the wait stops after 90s, and
--timeout sets another limit for anyone. The limit counts from the
command's first request, and each poll gets only what is left of it.

A wait that reaches its limit, or meets a status string doesn't know,
exits 7 with code wait_timeout, prints the last status on stdout and
names the resume command. The crawl keeps running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A request that ran past its time limit now fails with exit 7 rather than
as a bare network error, and string login --poll took any failure but a
busy server as the end of the code: it deleted the waiting sign-in. A
server that didn't answer in time hasn't spent the code either, so the
sign-in now stays saved, and the error says that string login --poll can
still finish it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
login --poll and trial claim --poll waited in silence for as long as
their code lived, longer than the two minutes some coding agents give a
command. They now use the waiter that sitemap --wait uses: under an
agent they stop after 90s, and --timeout sets another limit for anyone.
A wait that reaches its limit exits 7 with code wait_timeout, and the
sign-in or claim stays saved for the next --poll. Where no person
watches stderr at a terminal, the wait first says what it waits for and
how to resume, then prints a line every 15s.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Ctrl-C ended string with exit 130 and said nothing. The first Ctrl-C
now says what keeps running and the command that picks it up: a crawl
that --wait was watching, or a sign-in or claim that is still open. For
a request that changes something, it says the request may already have
been processed. On a person's terminal it clears the line first, and
under --json it prints the error envelope. Then string ends the way
SIGINT ends a program, so the shell sees 128+2 and a script that runs
string stops too; Windows still exits 130. A second Ctrl-C ends string
at once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Eight of the thirteen commands printed the help for all of string when
asked for theirs. Every command now has its own page: usage, examples,
what it prints and how it exits, what it costs, its flags, and where to
read more. --help, -h anywhere before --, and string help COMMAND all
print it without a request. -v prints the version, as --version does,
and string version adds the commit, its date, the system and the Go
version, as one object with --json. None of these starts the daily
update check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A mistyped command said only "Unknown command". Now a near miss of a
command, or a word other tools use for one (scrape, crawl, setup, auth,
credits, doctor), names the command meant, with the same command line
as the next step, and string exits 2 without running it. Every flag of
more than one word takes its camelCase, kebab-case and snake_case
spellings, the CLI's own flags and the global switches included, and a
near miss of any flag names the one meant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
string example.com said "Unknown command", and string fetch example.com
said "Invalid URL". A first argument with a dot or :// that is no
command is now fetched, and a URL with no scheme given to fetch,
request or sitemap submit gets https://, with a note on stderr that
names the URL string uses. A scheme in capitals works anywhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…agents

string help exit-codes, environment, formatting and agents cover what
no one command owns: what each exit code means and what to do next,
every variable string reads and what each request tells String, where
output goes and in what shape, and what changes under an agent. A near
miss of a topic names it. Under an agent, bare string, string help and
string --help start with three lines on where to find one command's
page and how to keep big pages out of its context.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s out

A --json error now always carries exit_code, retryable,
user_action_required and next_commands. retryable is the API's word, or
true after a rate limit, a failure at String or a timeout.
user_action_required is true when a person must act: a key, credit, a
crawl's approval, or a blocked network. Each of next_commands has a type
(fix_command, wait, retry, login, trial, env, pay or tell_user), so an
agent can take the steps that need no person. A request that got no
answer gives its reason: dns, connect or tls, and it can be sent again.
Inside a sandbox that blocks the network, the error says so, is not
retryable, and its step is to ask the person to let string reach the
host.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An error's text was its message, which for an API error held the status
and up to 2,000 characters of the raw body, an HTML page included, and
for a request that got no answer Go's own words, such as dial tcp. Now
the first line is error: and one sentence: the API's message with its
status when the API sends one, a short plain answer, or the CLI's own
sentence. The details follow, indented, then next: after a blank line.
A request that got no answer says whether the name didn't resolve, the
connection was refused, TLS failed, or the connection was lost.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--errors json gives JSON errors, as --json does, and leaves stdout as it
is, so a script can keep fetch's Markdown and still read errors as JSON
in 0.3 and 0.4 alike. fetch --json now says once, on stderr, that its
stdout becomes a JSON object in 0.4. A fetch whose site answered 404 or
410 warns that it will exit 8 then, and another error that it will exit
6, from the X-Status-Code the API sends. STRING_NO_DEPRECATION_WARNINGS=1
silences both, and so does STRING_COMPAT=0.2. string help formatting
lists the changes, and string help environment the two variables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
asavor and others added 14 commits November 20, 2026 06:10
…n 0.4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A fetched page over 16 KB now says its size on stderr before the page,
wherever no person reads stdout at a terminal: the bytes and tokens,
what the agent running string keeps of output that long, and the same
command with -o page.md. -o checks its path before the request, so a
bad path no longer spends the call, and says what it saved: the size,
the tokens, a fetch's status and host, and a Markdown page's outline,
each heading after the line it starts on. -o - is stdout. -q leaves
these status lines, and a wait's, out of stderr.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fetch --max-tokens N prints about N tokens of the page, at four
characters a token, and stderr says which part it is of how many and
gives the command for the next part. Parts end on whole tokens, mostly
at a line's end, so the next part starts exactly at its --offset and
the parts give the page back with nothing lost or repeated. The first
part saves a local copy for 15 minutes, readable only by its owner, and
the parts after it read that copy: no request, no credit, and no
keyless allowance spent. The size note for a large page now names
--max-tokens too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
whoami read only local files and always exited 0, so a key String had
revoked still looked fine. Now it checks the key with one request to
the balance endpoint, which spends no credit: it says the key's source,
the account it was saved for, the key's first characters and that
String accepts it; exits 3 when String refuses the key, with the step
for that source; and exits 6 when it couldn't ask. whoami --offline
keeps the old local-only answer, and --json gives one object.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…from stdin

A field that only comes back in JSON, such as --jsonSchema, with
--format markdown or raw was dropped without a word. It now exits 2 and
names the fix. request --body-file - reads the body from stdin, where it
used to look for a file called -; with --input - too, it exits 2, since
only one can read stdin. --body still sends its text as written, and
warns when it is @ and the name of a file that exists, since
--body-file was likely meant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…here

Page content is untrusted. When stdout is a person's terminal, a page
now loses ESC, so no escape sequence runs; every other control
character but tab and newline, C1 included; and bidi overrides and
isolates, which can make text read differently from its bytes. Bytes
that aren't text, such as a PDF from --format raw, are refused there
with exit 2 and the command with -o. Piped, or under a coding agent,
output goes out byte for byte, as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
string init now installs the string-cli skill in ~/.agents/skills, which
Codex, Cursor, Gemini CLI and most other agents read, and in
~/.claude/skills for Claude Code. An agent found here that reads neither
still gets a copy of its own. Releases before 0.3 put a copy in each
agent's directory, and Gemini CLI, which reads both ~/.gemini/skills and
~/.agents/skills, warned of a skill conflict at every start, so init
removes that copy and says so. It removes only a plain copy as init
wrote it; a link, extra files or another skill's name stay, with the
reason. --agent NAME still writes exactly the agents it names.

string skill prints the skill this release carries, so an agent can read
it without installing anything, and --path lists the installed copies.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The skill now teaches what 0.3 changes for agents: --errors json rather
than fetch --json, -o with the outline and sed -n, --max-tokens parts
from the local copy, exit 7 as "run the next command" for --poll and
--wait, whoami's check, the typed next_commands and the help topics.
Its description says when to reach for string: a page or search that
curl or WebFetch can't read, a crawl, or structured site data. The trial
key stays the fallback for when nobody can approve a key.

A test keeps it at 150 lines or fewer, and fails on a command or flag it
names that no help page has.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… skill does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@asavor asavor added claude PR primarily authored by Claude merge:same-repo-dependency Needs an unmerged PR in this repo first; no known cross-repo prerequisite. Checks and holds apply. labels Nov 20, 2026
@asavor asavor mentioned this pull request Nov 20, 2026
4 of 5 tasks
@asavor
asavor changed the base branch from terminal-safe to main November 20, 2026 16:40
@asavor
asavor merged commit df82142 into main Nov 21, 2026
5 checks passed
@asavor
asavor deleted the skill-dirs branch November 21, 2026 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude PR primarily authored by Claude merge:same-repo-dependency Needs an unmerged PR in this repo first; no known cross-repo prerequisite. Checks and holds apply.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant