Skip to content

feat(init): scaffold circleci init onboarding command#1290

Draft
Klaney wants to merge 1 commit into
nextfrom
Klaney/init-command
Draft

feat(init): scaffold circleci init onboarding command#1290
Klaney wants to merge 1 commit into
nextfrom
Klaney/init-command

Conversation

@Klaney
Copy link
Copy Markdown
Contributor

@Klaney Klaney commented May 11, 2026

Summary

Lands the command shell for the CLI onboarding flow (WEBXP-987) — the first slice of the CLI Onboarding (Phases 1–3) project.

  • Registers a new top-level circleci init command (single-verb, no subcommands).
  • Inside a git working tree, prints the four-phase preamble (scan → docker test → generate config → sign up) and stub [1/3] / [2/3] / [3/3] step lines that mirror the Figma prototype copy. Exits 0.
  • Outside a git repo, returns a structured ExitBadArguments (exit 2) error with a cd <path> suggestion.
  • Adds a permissive gitremote.InsideWorkTree() helper. gitremote.Detect() is too strict — it requires a parseable CircleCI remote that fresh init targets may not have yet.
  • Real scan / test / generate / signup logic is owned by follow-up tickets and intentionally not inlined here.

Local testing

# Build
task build

# Help text — lists all four phases
./dist/circleci init --help

# Happy path — exit 0, prints welcome + 3 stub step lines + signup CTA
mkdir /tmp/init-smoke && cd /tmp/init-smoke && git init
/path/to/dist/circleci init
echo "exit=$?"   # → 0

# Error path — exit 2 with `cd <path>` suggestion
mkdir /tmp/init-no-git && cd /tmp/init-no-git
/path/to/dist/circleci init
echo "exit=$?"   # → 2

# Or install to ~/.local/bin and run as `circleci init`
task dev-install
cd path/to/any/git/repo && circleci init

Test plan

  • task test passes (495 tests, includes new unit + acceptance suites)
  • task check is clean (lint, license headers, go mod tidy)
  • circleci init --help lists all four onboarding phases
  • circleci init inside a git repo exits 0 and prints the welcome banner, [1/3] / [2/3] / [3/3] stub lines, and the signup CTA with the signup URL
  • circleci init outside a git repo exits 2 and prints the "valid git repository" error with the cd <path> suggestion
  • circleci init foo rejects extra args (cobra.NoArgs) with exit 2

Out of scope (per WEBXP-987)

  • Real scan / test / config-generation / CIAM signup logic — each follow-up ticket
  • Interactive Enter-to-continue prompts, spinners, browser open
  • Telemetry hooks, localization
  • --json output (not a data-returning command)

🤖 Generated with Claude Code

Lands the shell for the CLI onboarding flow (WEBXP-987). Registers a
new top-level `init` subcommand that, from inside a git working tree,
prints the four-phase preamble (scan → docker test → generate config →
sign up) and stub `[1/3]/[2/3]/[3/3]` step lines that mirror the Figma
prototype copy. Outside a git repo it returns a structured
ExitBadArguments error with a `cd <path>` suggestion.

Adds a permissive `gitremote.InsideWorkTree()` helper (vs. the stricter
`Detect()`, which requires a parseable CircleCI remote that fresh `init`
targets may not have).

Real scan/test/generate/signup logic is owned by follow-up tickets and
intentionally not inlined here.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Klaney
Copy link
Copy Markdown
Contributor Author

Klaney commented May 11, 2026

Help output

Screenshot 2026-05-11 at 2 10 09 PM

Init in Empty Repo

Screenshot 2026-05-11 at 2 11 38 PM

Init in git repo

Screenshot 2026-05-11 at 2 07 17 PM

@Klaney Klaney marked this pull request as draft May 11, 2026 21:42
@Klaney
Copy link
Copy Markdown
Contributor Author

Klaney commented May 11, 2026

Putting this into draft mode for now. Gonna work on the other commands first. And compose them together later if need be.

Fab10-CircleCi added a commit that referenced this pull request May 15, 2026
Scaffolds the top-level `circleci init` command (WEBXP-987) and composes
it with the existing reposcan (WEBXP-988) + new testrunner (WEBXP-989)
work into a four-journey-item flow:

  [1/3] Scanning repository      — real, via internal/reposcan
  [2/3] Running tests in Docker  — real, via internal/testrunner
  [3/3] Generating config        — stub, owned by WEBXP-990
   Next: sign up for CircleCI    — post-flow CTA per Figma

Banner copy and step framing match the Figma onboarding board.
gitremote.InsideWorkTree() guards execution. Extra args are rejected
through the project's structured error pipeline (exit 2) instead of
cobra's default rendering.

Acceptance coverage: happy path, test-failure agent prompt, Docker
unavailable, non-git repo, and extra-args rejection. The acceptance
suite swaps the Docker runner for an in-memory fake via the
CIRCLECI_INIT_FAKE_RUNNER env hook so CI does not need a Docker daemon.

Supersedes draft PR #1290.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant