Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/init-adjustments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"clerk": patch
---

Tighten the `clerk init` bootstrap flow:

- Skip the redundant "Proceed?" scaffold confirmation when bootstrapping a new project (via `--starter` or on an empty directory). The scaffold plan is still previewed; only the now-superfluous prompt is removed since the user already opted in by starting bootstrap.
- Print bootstrap next steps (`cd <project>`, `<pm> dev`, etc.) after the optional "Install agent skills?" prompt so they remain the last thing visible when the command finishes.
70 changes: 70 additions & 0 deletions packages/cli-core/src/commands/init/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import * as scanMod from "./scan.ts";
import * as heuristics from "./heuristics.ts";
import * as skillsMod from "./skills.ts";
import * as bootstrapMod from "./bootstrap.ts";
import * as nextStepsMod from "../../lib/next-steps.ts";
import { init } from "./index.ts";

const FAKE_CTX = {
Expand Down Expand Up @@ -169,6 +170,75 @@ describe("init", () => {
expect(heuristics.printKeylessInfo).not.toHaveBeenCalled();
});

test("bootstrap flow skips scaffold Proceed? prompt (user already opted in)", async () => {
setup({ email: "test@test.com" });
setupBootstrapSuccess();
spyOn(scaffoldMod, "scaffold").mockResolvedValue({
actions: [{ type: "create", path: "app/layout.tsx", content: "", description: "" }],
postInstructions: [],
});

await init({});

expect(bootstrapMod.promptAndBootstrap).toHaveBeenCalled();
expect(previewMod.previewAndConfirm).not.toHaveBeenCalled();
expect(previewMod.previewPlan).toHaveBeenCalled();
});

test("--starter skips scaffold Proceed? prompt even without -y", async () => {
setup({ email: "test@test.com" });
spyOn(context, "gatherContext").mockResolvedValue(FAKE_CTX);
spyOn(config, "resolveProfile").mockResolvedValue({ profile: { appId: "app_123" } } as never);
spyOn(scaffoldMod, "scaffold").mockResolvedValue({
actions: [{ type: "create", path: "app/layout.tsx", content: "", description: "" }],
postInstructions: [],
});

await init({ starter: true });

expect(previewMod.previewAndConfirm).not.toHaveBeenCalled();
expect(previewMod.previewPlan).toHaveBeenCalled();
});

test("existing project without -y still prompts scaffold Proceed?", async () => {
setup({ email: "test@test.com" });
spyOn(context, "gatherContext").mockResolvedValue(FAKE_CTX);
spyOn(config, "resolveProfile").mockResolvedValue({ profile: { appId: "app_123" } } as never);
spyOn(scaffoldMod, "scaffold").mockResolvedValue({
actions: [{ type: "create", path: "app/layout.tsx", content: "", description: "" }],
postInstructions: [],
});

await init({});

expect(previewMod.previewAndConfirm).toHaveBeenCalled();
});

test("bootstrap prints next steps after skills install", async () => {
setup({ email: "test@test.com" });
setupBootstrapSuccess();
spyOn(scaffoldMod, "scaffold").mockResolvedValue({
actions: [{ type: "create", path: "app/layout.tsx", content: "", description: "" }],
postInstructions: [],
});

const callOrder: string[] = [];
spies.push(
spyOn(skillsMod, "installSkills").mockImplementation(async () => {
callOrder.push("installSkills");
}),
);
spies.push(
spyOn(nextStepsMod, "printNextSteps").mockImplementation(() => {
callOrder.push("printNextSteps");
}),
);

await init({});

expect(callOrder.indexOf("installSkills")).toBeLessThan(callOrder.indexOf("printNextSteps"));
});

test("blank dir with keyless framework auto-selects keyless when unauthenticated", async () => {
setup();

Expand Down
15 changes: 10 additions & 5 deletions packages/cli-core/src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ export async function init(options: InitOptions = {}) {

// Short-circuit on a fully-clean re-run so env pull / skills prompt don't
// execute when there's nothing to do.
const { alreadySetUp } = await detectAndInstall(ctx.cwd, ctx, overrides.skipConfirm);
// Bootstrap implies consent — the user already opted into project creation, so
// skip the scaffold "Proceed?" prompt as well.
const skipScaffoldConfirm = overrides.skipConfirm || bootstrap != null;
const { alreadySetUp } = await detectAndInstall(ctx.cwd, ctx, skipScaffoldConfirm);

if (alreadySetUp) {
log.success("\nClerk is already set up in this project.");
Expand All @@ -117,15 +120,17 @@ export async function init(options: InitOptions = {}) {
printKeylessInfo();
}

if (bootstrap) {
printBootstrapNextSteps(bootstrap, keyless);
}

if (options.skills !== false) {
bar();
await installSkills(ctx.cwd, ctx.framework.dep, ctx.packageManager, overrides.skipConfirm);
}

// Next steps print last so they stay on screen as the final thing the user sees.
if (bootstrap) {
bar();
printBootstrapNextSteps(bootstrap, keyless);
}

outro("Done");
}

Expand Down
Loading