Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/remove-init-prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"clerk": minor
---

Remove `clerk init --prompt` and the bundled per-framework agent prompt templates. Agents should run `clerk init -y` to perform the full setup non-interactively, or run `skills add clerk/skills` directly via their preferred package runner. The internal `pmInstallCommand` helper has moved from `commands/init/prompts/` to `lib/package-manager.ts`.
2 changes: 0 additions & 2 deletions packages/cli-core/src/cli-program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ Give AI agents better Clerk context: install the Clerk skills
)
.option("--name <project-name>", "Project name for --starter (skips prompt)")
.option("--app <id>", "Application ID to link (skips interactive picker)")
.option("--prompt", "Output a prompt for an AI agent to integrate Clerk")
.option("--starter", "Create a new project from a starter template")
.option("-y, --yes", "Skip confirmation prompts")
.option("--no-skills", "Skip the optional agent skills install prompt")
Expand All @@ -150,7 +149,6 @@ Give AI agents better Clerk context: install the Clerk skills
command: "clerk init --starter --framework next --pm bun",
description: "Bootstrap with Bun",
},
{ command: "clerk init --prompt", description: "Output a setup prompt for an AI agent" },
{ command: "clerk init -y", description: "Skip all confirmation prompts" },
{ command: "clerk init --no-skills", description: "Skip the agent skills install prompt" },
])
Expand Down
38 changes: 16 additions & 22 deletions packages/cli-core/src/commands/init/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ clerk init --framework next
clerk init --starter
clerk init --starter --framework next --pm bun
clerk init --starter --framework next --pm bun --name my-app
clerk init --prompt
clerk init -y
clerk init --yes
clerk init --no-skills
Expand All @@ -26,7 +25,6 @@ clerk init --no-skills
| `--name <project-name>` | Project name for `--starter` (skips prompt). Must be lowercase, no spaces, no path separators |
| `--app <id>` | Application ID to link (skips the interactive app picker during authenticated linking) |
| `--starter` | Bootstrap a new project from a starter template (runs the framework generator, installs deps, and scaffolds Clerk) |
| `--prompt` | Output a prompt for an AI agent to integrate Clerk, then exit |
| `-y, --yes` | Skip confirmation prompts (also skips authentication after bootstrap, letting you connect your account later) |
| `--no-skills` | Skip the optional agent skills install prompt at the end of init |

Expand All @@ -39,31 +37,28 @@ When running in agent mode (`--mode agent` or non-TTY), the command runs the ful
- For **new projects** (`--starter` or blank directory): `--framework` is required (no way to auto-detect in an empty dir). Package manager is auto-selected by availability (bun → pnpm → yarn → npm) unless `--pm` is provided
- Project name defaults to the framework's default (e.g. `my-clerk-next-app`) unless `--name` is provided

Use `--prompt` to output a setup prompt for an AI agent without running init.

## Flow

1. **`--prompt`**: outputs a framework-specific prompt, then exits
2. Gathers project context (framework, router variant, TypeScript, `src/` directory, package manager)
3. Determines auth mode from credential presence (no user prompt):
1. Gathers project context (framework, router variant, TypeScript, `src/` directory, package manager)
2. Determines auth mode from credential presence (no user prompt):
- **Authenticated** (OAuth token or `CLERK_PLATFORM_API_KEY` set): uses the authenticated flow — runs `clerk link` if not already linked and pulls real API keys into `.env` at the end
- **Bootstrap + keyless-capable framework + not authenticated**: automatically uses keyless mode — the app runs on auto-generated dev keys and the user can connect a Clerk account later with `clerk auth login`
- **Bootstrap + non-keyless framework + not authenticated** (with `--yes` or agent mode): skips authentication and prints manual setup instructions (run `clerk auth login` / `clerk link` / `clerk env pull` when ready)
- **Existing project + not authenticated**: runs the authenticated flow, which triggers an interactive login so real keys can be pulled
4. **Authenticated mode only**: authenticates via `clerk auth login` (skipped if already authenticated) and links the project via `clerk link` (skipped if already linked)
5. Displays detected framework and variant
6. Detects existing auth libraries (NextAuth, Auth0, Supabase, Firebase, Passport, Better Auth, Kinde) and shows migration guidance
7. Installs the appropriate Clerk SDK (skips if already present)
8. Generates a scaffold plan for the detected framework
9. Warns if the git working tree has uncommitted changes
10. Previews planned file changes and asks for confirmation
11. Writes scaffold files to disk
12. Runs project formatters (Prettier/Biome) on generated files
13. Scans for issues: hardcoded keys, leftover auth-library imports, stale API calls
14. Prints a summary of created, modified, and skipped files with recommendations
15. **Authenticated mode**: pulls development instance API keys via `clerk env pull`
16. **Unauthenticated mode**: prints instructions for development without API keys and how to connect a Clerk account later
17. Optionally installs Clerk agent skills (core + features, plus a framework-specific skill) via the project's package runner (see [Agent skills install](#agent-skills-install))
3. **Authenticated mode only**: authenticates via `clerk auth login` (skipped if already authenticated) and links the project via `clerk link` (skipped if already linked)
4. Displays detected framework and variant
5. Detects existing auth libraries (NextAuth, Auth0, Supabase, Firebase, Passport, Better Auth, Kinde) and shows migration guidance
6. Installs the appropriate Clerk SDK (skips if already present)
7. Generates a scaffold plan for the detected framework
8. Warns if the git working tree has uncommitted changes
9. Previews planned file changes and asks for confirmation
10. Writes scaffold files to disk
11. Runs project formatters (Prettier/Biome) on generated files
12. Scans for issues: hardcoded keys, leftover auth-library imports, stale API calls
13. Prints a summary of created, modified, and skipped files with recommendations
14. **Authenticated mode**: pulls development instance API keys via `clerk env pull`
15. **Unauthenticated mode**: prints instructions for development without API keys and how to connect a Clerk account later
16. Optionally installs Clerk agent skills (core + features, plus a framework-specific skill) via the project's package runner (see [Agent skills install](#agent-skills-install))

## Framework Detection

Expand Down Expand Up @@ -185,7 +180,6 @@ After scaffolding (and after env keys are pulled or keyless instructions are pri

- **Human mode**: prompts `Install agent skills? (...)` defaulting to yes. Pass `--no-skills` to suppress the prompt entirely, or `-y/--yes` to accept it without confirmation. When more than one runner is available, a second prompt picks which one to use (the project's package manager wins by default).
- **Agent mode**: skills are installed non-interactively with `-y -g` flags (no prompt shown). Pass `--no-skills` to skip entirely.
- **`--prompt`**: exits before the skills step runs. Agent users should run `skills add clerk/skills` via their preferred runner manually; the bundled `clerk` skill is only installable via `clerk init` itself, since its source lives inside the CLI binary.

Two install commands run, sharing one runner:

Expand Down
2 changes: 1 addition & 1 deletion packages/cli-core/src/commands/init/heuristics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { log } from "../../lib/log.js";
import { getValidToken, hasStoredCredentials } from "../../lib/credential-store.js";
import { fetchUserInfo } from "../../lib/token-exchange.js";
import { printFindings } from "./scan.js";
import { pmInstallCommand } from "./prompts/index.js";
import { pmInstallCommand } from "../../lib/package-manager.js";
import { withSpinner } from "../../lib/spinner.js";
import type { FileAction, ProjectContext, ScaffoldPlan } from "./frameworks/types.js";
import type { ScanFinding } from "./scan.js";
Expand Down
10 changes: 0 additions & 10 deletions packages/cli-core/src/commands/init/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,16 +169,6 @@ describe("init", () => {
expect(bootstrapMod.promptAndBootstrap).not.toHaveBeenCalled();
});

test("--prompt flag prints guidance and exits", async () => {
const { captured } = setup({ isAgent: false });

await captured.run(() => init({ prompt: true }));

expect(captured.out).toContain("clerk init -y");
expect(loginMod.login).not.toHaveBeenCalled();
expect(bootstrapMod.promptAndBootstrap).not.toHaveBeenCalled();
});

test("blank dir in human mode triggers bootstrap flow", async () => {
setup();
setupBootstrapSuccess();
Expand Down
9 changes: 0 additions & 9 deletions packages/cli-core/src/commands/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ type InitOptions = {
pm?: PackageManager;
name?: string;
yes?: boolean;
/** Output a prompt for an AI agent to integrate Clerk, then exit. */
prompt?: boolean;
/** Install the optional agent skills (set to false via `--no-skills` to skip). */
skills?: boolean;
/** Create a new project from a starter template. */
Expand All @@ -63,13 +61,6 @@ export async function init(options: InitOptions = {}) {
? (lookupFramework(options.framework) ?? undefined)
: undefined;

if (options.prompt) {
log.data(
"Run `clerk init -y` to automatically detect the framework, install the Clerk SDK, and scaffold authentication files without interactive prompts.",
);
return;
}

// In agent mode, implicitly enable --yes to skip all confirmation prompts.
const overrides: BootstrapOverrides = {
skipConfirm: options.yes || isAgent(),
Expand Down
113 changes: 0 additions & 113 deletions packages/cli-core/src/commands/init/prompts/astro.md

This file was deleted.

119 changes: 0 additions & 119 deletions packages/cli-core/src/commands/init/prompts/expo.md

This file was deleted.

Loading
Loading