You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(init): support local debugging of clerk-cli skill source
Extends the clerk-cli skill source resolver from a CLI_VERSION-only
lookup to a four-tier flow:
1. CLERK_CLI_SKILL_SOURCE env var (explicit override, any mode)
2. CLI_VERSION → matching v${version} tag URL (released binary)
3. Local working-tree path resolved via import.meta.url (bun run dev
from a checked-out repo)
4. tree/main/skills/clerk-cli (compiled local binary fallback)
The local working-tree path resolution is the killer feature for
developer iteration: edit skills/clerk-cli/SKILL.md in your checkout,
re-run `bun run dev -- init`, and the installer reads your working
tree directly. No push, no rebuild, uncommitted edits visible.
resolveSkillSource is exported as a pure function (takes its three
inputs as plain arguments) so it's testable without mocking process.env,
CLI_VERSION, or the filesystem. Adds 9 unit tests covering every branch.
Copy file name to clipboardExpand all lines: packages/cli-core/src/commands/init/README.md
+25-6Lines changed: 25 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -160,17 +160,36 @@ After scaffolding (and after env keys are pulled or keyless instructions are pri
160
160
161
161
Two install commands run, sharing one runner:
162
162
163
-
### 1. The version-pinned `clerk-cli` skill
163
+
### 1. The `clerk-cli` skill (from this repo)
164
164
165
165
The `clerk-cli` skill ships **from this repo** at [`<repo-root>/skills/clerk-cli/`](../../../../../skills/clerk-cli/). It is **not** bundled into the binary, it's fetched at install time by the `skills` CLI, the same way any other skill would be.
166
166
167
-
The source URL is constructed from `CLI_VERSION` (the compile-time global injected by `scripts/build.ts`):
167
+
The source is resolved by [`resolveSkillSource()`](./skills.ts) in this priority order:
1.**`CLERK_CLI_SKILL_SOURCE` env var**, explicit override. Accepts any source the `skills` CLI accepts (github URL, gitlab URL, local path, git URL). Wins over everything else, in any build mode. Use this for testing forks, feature branches, or custom builds. Label: `custom`.
170
+
2.**`CLI_VERSION` injected at compile time**, released binary path. Builds the URL `https://github.com/clerk/cli/tree/v${CLI_VERSION}/skills/clerk-cli`. Every published release (stable, canary, snapshot) tags as `v${CLI_VERSION}` (see `.github/workflows/release.yml` and `scripts/snapshot.ts`), so the same template works for all of them. Label: `v0.0.2` (or whatever the version is).
171
+
3.**Local working-tree path**, dev mode auto-detection. When running via `bun run dev` from a checked-out copy of this repo, [`resolveLocalSkillPath()`](./skills.ts) walks back from `import.meta.url` to `<repo-root>/skills/clerk-cli/` and passes the **filesystem path** as the source. Working-tree edits (committed or not) are picked up immediately, no push, no rebuild. In compiled binaries, `import.meta.url` resolves to a virtual bundle path that doesn't exist on disk, so `existsSync` returns false and this branch is skipped. Label: `local`.
172
+
4.**`tree/main/skills/clerk-cli` fallback**, last resort for compiled local binaries (`bun run build:compile` without `--version`) where neither the env var nor a local working tree is available. Label: `main`.
173
+
174
+
The label appears in the install heading (e.g. `Installing clerk-cli skill (local) with bunx...`) so the developer can tell at a glance which source the installer is hitting.
175
+
176
+
#### Local debugging
172
177
173
-
Every published release (stable, canary, and snapshot) tags as `v${CLI_VERSION}` (see `.github/workflows/release.yml`), so the same `tree/v<version>/skills/clerk-cli` URL works for all of them. The only case without a matching tag is the local-dev sentinel `0.0.0-dev` (set by `scripts/build.ts` when no `--version` is passed), which falls back to `main`.
178
+
Two ways to test changes to the skill content:
179
+
180
+
```sh
181
+
# 1. Edit-then-run loop (the most common case): just edit the file and re-run.
182
+
# bun run dev auto-detects the local working-tree path, so uncommitted
183
+
# edits are visible to the installer immediately.
184
+
$EDITOR skills/clerk-cli/SKILL.md
185
+
bun run dev -- init # Installing clerk-cli skill (local) with ...
186
+
187
+
# 2. Test against a remote source: set CLERK_CLI_SKILL_SOURCE to override.
188
+
# Useful for QA-ing a feature branch, a fork, or a release candidate
0 commit comments