Skip to content

Read use_for in the Claude Code plugin's skill list and find the project under any spelling of its remote - #3645

Merged
malibio merged 2 commits into
mainfrom
issue-3643-plugin-list-and-lookup
Oct 5, 2026
Merged

malibio merged 2 commits into
mainfrom
issue-3643-plugin-list-and-lookup

Conversation

@malibio

@malibio malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

Closes #3643

What this fixes

Two defects found by running the merged Claude Code plugin against a real daemon built from main.

  • The skill list showed no descriptions. The plugin read description from nodespace --json skill guidance; a listing entry carries use_for. It now reads use_for, and its own field is renamed to match. No fallback to the old name.
  • A project saved with another spelling of its repository was not found. The lookup sent one equals filter with the HTTPS form without .git. It now sends an in filter over the six common spellings: HTTPS, git@host:path and ssh://git@host/path, each with and without .git.

Why the tests missed it

The plugin's tests answer from a fake CLI, which still returned description. The fake now returns use_for and the {count, nodes} shape the project query prints. A new scripts test, which runs in the merge gate, ties the fields skillsOf reads to the ones skill_json prints in packages/cli/src/commands/skill.rs, so a rename on either side fails there.

Verification

  • Live, against a daemon on a throwaway NODESPACE_HOME with a project whose repository.url ends in .git: the session's system prompt section listed all 12 seeded skills with their text. Before the fix the same setup found no project.
  • bun run --cwd packages/skill test:plugin: validate passed, 34 plugin tests passed.
  • bun test scripts/publish-skill-repo.test.ts: 34 passed.
  • bun run test:changed: passed.

🤖 Generated with Claude Code

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Pragmatic Code Review: PR #3645

Review Type: Initial review (no earlier reviews or comments on the PR)

Summary

APPROVE. Both defects are fixed at their cause, with no fallback to the old field name, and the change is a clear net improvement. Nothing blocks the merge. Three improvements are worth folding in, all the same shape as the bugs this PR fixes: the lookup still misses a project saved with the checkout's own remote when that remote has a port, a user or a non-HTTPS scheme; findProject still reads a bare-array shape the CLI does not print; and the CLI manual still teaches the equals lookup.

What I ran:

  • bun run --cwd packages/skill test:plugin: validation passed, 34 tests passed.
  • bun test scripts/publish-skill-repo.test.ts: 34 passed.
  • A read-only mutation check of the new gate test's logic against in-memory copies of both sources (results under Findings).

I did not run bun run test:changed, quality:fix, the Rust suite or a live session.

Requirements Check (issue #3643)

  • ✅ The section lists each skill as its title and its use_for. skillsOf reads entry.use_for; buildSection prints it. The existing section test asserts - Implementing a task: when Implementing a task applies against a fake that now returns use_for.
  • ✅ A skill whose use_for changed is named as changed in the note. listNote compares useFor; the test asserts the new text appears on the Changed line. (The test changes modified_at in the same edit, so the useFor comparison alone is not isolated. See the nit.)
  • ✅ A project is found whether saved as HTTPS or SSH, with or without .git. One in filter over six spellings. The in operator builds json_extract(...) IN (?, ...) with one bound parameter per member (packages/core/src/services/query_service/mod.rs:1191-1204), so the filter shape is right and every value is bound. Gaps beyond these six are finding 1.
  • ✅ The fake CLI returns use_for, and {count, nodes} for the project query. It matches print_node_list (packages/cli/src/output.rs:141-149), collection_id included.
  • ✅ A merge-gate test fails if the listing field the plugin reads is not one skill_json prints. Confirmed by mutation, below.
  • ⚠️ Verified in a live session on a throwaway NODESPACE_HOME. Stated in the PR body; I did not repeat it.
  • ✅ bun run --cwd packages/skill test:plugin passes. 34 passed here.
  • ⚠️ bun run quality:fix and bun run test:changed. Stated in the PR body; not re-run.

Code Review Findings

Critical Issues

None.

Suggested Improvements

1. 🟡 The spelling list omits the checkout's own remote when it has a port, a user or another scheme
📁 packages/skill/plugins/claude-code/hooks/register.ts:145-153, :271-280

httpsRemote drops the port, the user and the scheme, and remoteSpellings rebuilds six strings from what is left. So the list can lack the exact string git remote get-url origin printed, which is the string a project's author is most likely to have pasted.

Failure scenarios, each returning "no project for this checkout" with no error:

Remote of the checkout, saved verbatim as repository.url Why none of the six match
https://gitlab.example.com:8443/group/repo.git The port is dropped
ssh://[email protected]:2222/group/repo.git The port is dropped
http://git.internal/acme/widgets.git Only https:// is generated
https://[email protected]/org/proj/_git/repo The user is dropped
[email protected]:acme/widgets.git Only the git@ user is generated

Other misses, by the same exact, case-sensitive IN:

  • A stored URL with a trailing slash (https://github.com/acme/widgets/).
  • A difference in case: a checkout cloned as [email protected]:Acme/Widgets.git against a project saved as https://github.com/acme/widgets. GitHub treats both as one repository.

None of these is a regression: the old equals missed them too. But ADR-092 §4 says two spellings of one remote compare equal, and this PR is the one that makes the lookup tolerant.

Recommendation, in order of cost:

  • Cheap, in this PR: add the trimmed raw remote to the list (deduplicated), so a project saved with the checkout's own remote is always found. That covers all five rows of the table.
  • More complete, if you want it: compare on the client with the normalizer that already exists. Query the projects that have a repository (exists on repository.url) and keep the one where httpsRemote(stored) === url. Every spelling httpsRemote understands then matches (ports, users, schemes, trailing slashes), and lower-casing the host in httpsRemote covers host case. The cost is reading every project with a repository rather than one row, and the query's default limit of 50 has to be raised.

Principle: one normalizer on both sides of a comparison beats enumerating one side's outputs; an enumerated list is correct only for the cases someone thought of.

2. 🟡 findProject still accepts a bare array, a shape nodespace query does not print
📁 packages/skill/plugins/claude-code/hooks/register.ts:291

const node = list(isRecord(parsed) ? parsed.nodes : parsed).find(isRecord)

nodespace --json query prints {count, collection_id, nodes} and nothing else. Until this PR the fake CLI answered with a bare array, so the : parsed branch was the only one the tests ran; now that the fake prints the real shape, the branch is untested and reads a shape that does not exist. It is the same defect class as the description read: plugin code written against the fake rather than the CLI. CLAUDE.md also rules out reading a second shape.

Recommendation: list(isRecord(parsed) ? parsed.nodes : []).

Principle: YAGNI; no dual-shape reads (CLAUDE.md, no compatibility code).

3. 🟡 The CLI manual still teaches the lookup this PR fixes, and still describes the output as a bare array
📁 packages/skill/references/cli.md:340, :347

  • Line 340, the worked example "the project for this repository", uses equals with <remote url>. An agent following the manual, in a harness with no plugin, hits the original bug: a project saved with .git or as SSH is not found.
  • Line 347 says **Output:** JSON array of matching nodes. The command prints {count, collection_id, nodes}. This line is the likely origin of the bare-array branch in finding 2.

Recommendation: change the example to in over the spellings (or say to pass each spelling of the remote), and correct the output line. The file is not at a size cap; only SKILL.md is.

Principle: the CLI operations are a contract (ADR-093, Consequences); the manual is where that contract is written down.

4. 🟢 The gate test ties four of the names the plugin reads; the rest of the contract is still held only by the fake
📁 scripts/publish-skill-repo.test.ts:265-279

The test does what the acceptance criterion asks. I checked it by mutation, on in-memory copies of both files:

Mutation Test
none passes
CLI renames the use_for key fails
CLI renames the modified_at key fails
CLI renames skill_json fails
plugin reads entry.description again fails
plugin renames skillsOf fails
plugin reads an extra field fails

So a rename on either side fails the gate, and a broken regex fails loudly rather than passing on an empty match.

What it does not cover, by the same mechanism that caused this bug (the fake and the plugin agreeing with each other, not with the CLI):

  • the listing's top-level guidance and version keys (register.ts:160, :261, :846);
  • the query's nodes key (:291);
  • the context read's node, paths[].path, paths[].nodes, attached_skills.guidance and version (:609-642, :709), and items[].node for a queue run (:528-531).

I compared each of these with packages/cli/src/output.rs and skill.rs by hand: all of them match what the CLI prints today, so nothing else in the plugin reads a stale name. Optional: extend the test to the guidance / version / nodes keys, which are cheap to tie the same way. Not needed for this PR.

Nitpicks

  • Nit: packages/skill/plugins/claude-code/hooks/register.ts:148-150: the host === '' branch of remoteSpellings cannot be reached from findProject (httpsRemote only returns https://host/path) and no test runs it. Either drop it or give it a test.
  • Nit: packages/skill/plugins/claude-code/hooks/register.ts:33: MAX_DESCRIPTION_CHARS keeps the old word now that the field is useFor; it also caps titles. A neutral name (MAX_LISTED_CHARS) would match the rename.
  • Nit: packages/skill/plugins/claude-code/tests/register.test.ts:336: the changed skill gets a new modified_at and a new use_for together, so the old.useFor !== skill.useFor comparison is never the only thing that differs. A case that keeps modified_at and changes only use_for would pin that line.
  • Nit (docs, outside this PR): ADR-093's operations table still says the list carries each skill's "title and description"; the architecture page already says use_for.

Recommendation

APPROVE. Findings 1 to 3 are worth folding into this PR, since each is a sibling of the bug being fixed and each is a few lines: add the raw remote to the spelling list, drop the bare-array read, and correct the two lines of cli.md. None of them blocks the merge.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated pragmatic-code-review: APPROVE (posted as a comment — GitHub blocks self-approval). Full findings in the review comment above.

@malibio

malibio commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator Author

Review addressed (commit 7480c20)

Addressed

  • 1. The checkout's own remote. The spelling list now also holds the remote exactly as git remote get-url origin printed it (trimmed, deduplicated), so a project saved with a port, a user or another scheme is found. Test with an SSH remote on a port.
  • 2. Bare-array read. findProject reads nodes from the object the query prints and nothing else.
  • 3. The manual. references/cli.md shows the project lookup with in over the spellings and says why, and the query's output line now reads {count, collection_id, nodes}.
  • Nits: the unreachable branch in remoteSpellings is gone; MAX_DESCRIPTION_CHARS is MAX_LISTED_CHARS; a new test changes a skill's use_for alone and expects it named as changed.

Skipped

  • Trailing slash and host case on the stored side. An exact in cannot cover them, and comparing on the client means reading every project with a repository. Revisit if a real project misses.
  • 4. Tying the remaining keys in the gate. The reviewer checked them by hand and found them current; optional.
  • ADR-093's "title and description". It reads as the plain word in a decision record, not the field name.

Plugin tests: 36 passed. Scripts: 34 passed. bun run test:changed: passed.

Re-review: not needed. The changes are a few lines each, local, and each has a test or is documentation.

malibio and others added 2 commits October 5, 2026 22:04
… every spelling of the remote (closes #3643)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…e query shape, correct the manual (#3643)

- The spelling list includes the remote as written, for one with a port,
  a user or another scheme
- findProject reads the shape the query prints and no other
- references/cli.md shows the lookup with in, and the query's real output
- A test for a skill whose text alone changed

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

Fix the Claude Code plugin's skill list reading a renamed field, and its project lookup missing a repository stored with another spelling

1 participant