Skip to content

feat(claude): search for an existing tool before writing one - #88

Merged
thompsonson merged 1 commit into
mainfrom
chore/search-before-building
Sep 20, 2026
Merged

thompsonson merged 1 commit into
mainfrom
chore/search-before-building

Conversation

@thompsonson

Copy link
Copy Markdown
Owner

Twice now a script has been written and thrown away because an equivalent already existed. This adds the rule that would have caught both.

Today's instance

I wrote a GitHub Actions runner setup script for thompsonson/atomicguard, staged it on computer, and had it reviewed twice. setup-gha-runner.sh was already sitting in ~mt on that same machine, and on main in thompsonson/dev at scripts/gha-runner/.

The existing one was better in ways that mattered:

  • It runs bin/installdependencies.sh. Mine skipped it, so my runner would most likely have failed to start.
  • It waits for Listening for Jobs in the journal. Mine gated on systemctl is-active, which is true for a service that is up but not talking to GitHub.
  • It preflights isolation, including that sudo -u gha-runner ls /home/mt fails. That machine holds GPG secret keys.

Why the searches missed it

I looked in dotfiles and in the host's PATH. Neither covers a script in a user's home directory, or one in a sibling repository. gh search code --owner thompsonson found it in one call.

The rule

## Before you build

- Search for an existing script or tool before writing a new one.
- Look in the repository, in my other repositories, and in the home directory of the machine that will run it.
- `gh search code --owner thompsonson "<distinctive string>"` finds it when a local search does not.
- Improve what exists rather than writing a second one beside it.
- Say what you searched, so I can point you at what you missed.

The last bullet is the cheap one: saying where I looked lets you correct a wrong guess before the work is done, rather than after.

./tests/test.sh quick passes, 7/7.

https://claude.ai/code/session_01VUd2Wv3nkSBpWgYBK6yhfh

Twice now a script has been written and thrown away because an equivalent
already existed.

Today: a GitHub Actions runner setup script, written from scratch and reviewed
twice, when `setup-gha-runner.sh` was already in ~mt on the host that runs it
and on main in thompsonson/dev. The existing one was better — it runs
installdependencies.sh, waits for "Listening for Jobs" rather than trusting
systemctl is-active, and preflights that the runner user cannot read ~mt.

The searches that missed it looked in dotfiles and in the host's PATH. The ones
that would have found it: the home directory of the machine that runs it, and
`gh search code --owner`.

Claude-Session: https://claude.ai/code/session_01VUd2Wv3nkSBpWgYBK6yhfh
@thompsonson
thompsonson merged commit fe31109 into main Sep 20, 2026
4 checks passed
@thompsonson
thompsonson deleted the chore/search-before-building branch September 20, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant