Improve Packref agent skill package inspection workflow - #47
Improve Packref agent skill package inspection workflow#47adelrodriguez wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
ℹ️ No correctness problems — two coverage gaps inline and one scope question below.
Reviewed changes — a docs-only rewrite of the first-party Packref agent skill, plus its changeset. I checked every command, path, and behavioral claim in the new prose against src/commands/*.ts and src/lib/.
- Missing-lockfile branch made explicit — step 1 now tells the agent to explain that the project is not initialized instead of proceeding, and gates
npx packref initbehind user authorization. - Identity-before-command sequencing — step 3 resolves the package identity and reference path before steps 4/5 decide whether to run anything, keeping the non-mutating
installdistinct fromadd. syncdescription corrected — the command-boundaries bullet now states thatsynccan update or remove references, which matchesSyncPlan.removals/SyncResult.removedinsrc/commands/sync.ts.installclaim verified — "restores all locked references without changing the lockfile" holds;installPackageReferencesonly reads the lockfile (src/lib/references/install.ts:128).- Path examples verified —
.packref/packages/npm/@effect/platform/0.90.0/and.packref/packages/npm/react/19.1.0/match the layout insrc/lib/workspace/paths.tsand the reference tests. - Changeset —
patch, consistent with prior practice (CHANGELOG.md0.2.0 already carries a changeset entry for a skill-only change).
ℹ️ Command guidance now lives in two places and only one was improved
The same command boundaries are documented twice: in this skill, and in the AGENTS.md section template at src/lib/workspace/integration.ts, which ships in dist and is written into every project by packref init. The template is what most agents actually read, and it still describes sync as update-only with none of the authorization guardrails this PR adds. Worth deciding whether the two should track each other or whether the skill is intentionally the richer artifact.
Technical details
# Skill guidance and the shipped AGENTS.md template have diverged
## Affected sites
- `src/lib/workspace/integration.ts:37` — `packref sync` is described as "update dependency-tracked lock entries to match current `package.json` dependency versions", with no mention that it can remove references. `skills/packref/SKILL.md:50-51` now correctly says it can.
- `src/lib/workspace/integration.ts:32-41` — the template's command list carries no "only when the user requests it" guardrails for `remove`, `prune`, `clean`, or `clean --global`. `skills/packref/SKILL.md:52-55` does.
## Required outcome
- A decision on whether the AGENTS.md template is meant to stay a short reference card (in which case nothing to do) or the primary agent-facing contract (in which case the `sync` removal behavior and the destructive-command guardrails should propagate).
- If they are meant to track each other, the divergence should not be able to reappear silently on the next edit to either file.
## Open questions for the human
- Is `skills/packref/SKILL.md` the source of truth for agent guidance, with the AGENTS.md section deliberately abbreviated?Claude Opus | 𝕏
| requests their destructive scope. | ||
| - `npx packref init` initializes a project. Run it only with user authorization. It is interactive | ||
| and can update `.gitignore`, `tsconfig.json`, `AGENTS.md`, the Packref lockfile, and Packref's | ||
| global project registration. |
There was a problem hiding this comment.
This says init "is interactive", but the command has a non-interactive mode built specifically for coding agents: --non-interactive combined with --ignore and --agents (src/commands/init.ts:20-30). Since this skill's whole audience is agents, worth naming that path — and noting that --ignore/--agents without --non-interactive fail with InitFlagsRequireNonInteractiveError (src/commands/init.ts:51-53), which is an easy trap to walk into.
| and can update `.gitignore`, `tsconfig.json`, `AGENTS.md`, the Packref lockfile, and Packref's | ||
| global project registration. | ||
| - `npx packref add [package-spec]` resolves and materializes a missing reference. Without a package | ||
| spec, it opens an interactive dependency selector. |
There was a problem hiding this comment.
Both this bullet and step 5 read as registry-only, but packref add also accepts a direct repository spec, e.g. packref add metaideas/packref (src/commands/add.ts:19-23). The skill already explains source.directory provenance for repository-sourced entries, so an agent can encounter one without ever learning how to create one — and @<version> is the wrong mental model for those.


This patch refines the Packref agent skill's inspection workflow with clearer sequencing and more precise language throughout.
The workflow now explicitly handles the case where
.packref/packref-lock.jsonis absent, directing the agent to explain that the project is not initialized rather than proceeding silently. Step 3 is restructured to first identify the exact package identity and local source path before deciding whether to run any command, making the distinction betweennpx packref install(restores locked references without side effects) andnpx packref addornpx packref sync(which can change or remove project state) more explicit.The command boundaries section is rewritten to describe each command's behavior and guard conditions in consistent imperative form, reinforcing which commands are safe to run autonomously and which require explicit user authorization or request.
The examples are tightened to show the full path after lockfile matching and to clarify that
npx packref addshould only run when the task scope includes obtaining new source. The failure and fallback section now directs the agent to read the error before taking any corrective action.