Skip to content

feat(cli): add wizard cli add to install agent steering instructions#646

Open
cvolzer3 wants to merge 2 commits into
mainfrom
feat/cli-steering-install
Open

feat(cli): add wizard cli add to install agent steering instructions#646
cvolzer3 wants to merge 2 commits into
mainfrom
feat/cli-steering-install

Conversation

@cvolzer3

@cvolzer3 cvolzer3 commented Jun 11, 2026

Copy link
Copy Markdown

Problem

Coding agents don't know that posthog-cli api exists unless something tells them. The CLI can install its steering snippet into a repo's AGENTS.md (posthog-cli api agents-md install), but there's no easy way to set it up globally — in the per-user instructions file of whichever agent someone uses (Claude Code's ~/.claude/CLAUDE.md, Codex's ~/.codex/AGENTS.md, …).

Per product direction, this should not be a new wizard screen, nor an option on the MCP install screen — it's a standalone command.

Changes

  • New wizard cli add command (src/commands/cli/):
    • Detects installed agents (Claude Code, Codex, Gemini CLI) by their home config directories.
    • One detected agent → installs straight away; several → minimal numbered selection with an "All of the above" option (plain readline, intentionally not a TUI flow); non-interactive shells install for all detected agents, mirroring how MCP install treats all supported clients.
    • --all installs for every detected agent without prompting (rejected when combined with --agent/--path); --agent <id> and --path <file> for explicit/headless use.
  • New src/steps/install-cli-steering/ step that delegates the actual write to npx -y @posthog/cli@latest api agents-md install --path <file>. The steering snippet's single source of truth stays in the CLI, and pinning to @latest means a rerun always refreshes the installed <posthog> block to current content instead of baking a copy into the wizard that would go stale.
    • The step is only referenced by the cli add command — it is not wired into any onboarding program. It lives in steps/ (mirroring add-mcp-server-to-clients) so a program could adopt it later as an explicit product decision.

Dependency: the api command group ships in the next @posthog/cli release (PostHog/posthog branch codex/agentic-cli-api-tools). Until then the command fails with a clear error from the published CLI ("unrecognized subcommand 'api'"). Keeping this as a draft until that lands.

Test plan

  • pnpm jest src/steps/install-cli-steering — 6 new unit tests (target mapping, detection, npx delegation incl. failure modes).
  • pnpm build && pnpm test && pnpm fix — green except src/__tests__/provision-cli.test.ts, which fails identically on a clean checkout of main.
  • Manual: node dist/bin.js cli add --help, node dist/bin.js cli add --path /tmp/x/AGENTS.md (surfaces the published CLI's missing-subcommand error cleanly, exit 1), node dist/bin.js cli add --all --agent claude-code (rejected by the cross-flag check).

LLM context

Implemented with Claude Code; design follows the existing mcp add command and add-mcp-server-to-clients step patterns.

Adds a headless `wizard cli add` command that writes the PostHog CLI
steering snippet into a coding agent's global instructions file
(Claude Code ~/.claude/CLAUDE.md, Codex ~/.codex/AGENTS.md, Gemini CLI
~/.gemini/GEMINI.md, or any file via --path). Detected agents are
offered as a numbered selection; non-interactive shells install for
all detected agents, mirroring the MCP install behavior.

The write is delegated to `npx -y @posthog/cli@latest api agents-md
install`, so the snippet's single source of truth stays in the CLI and
reruns always refresh the installed <posthog> block to the latest
published content.
@github-actions

Copy link
Copy Markdown

🧙 Wizard CI

Run the Wizard CI and test your changes against wizard-workbench example apps by replying with a GitHub comment using one of the following commands:

Test all apps:

  • /wizard-ci all

Test all apps in a directory:

  • /wizard-ci basic-integration
  • /wizard-ci error-tracking-upload-source-maps
  • /wizard-ci misc
  • /wizard-ci revenue

Test an individual app:

  • /wizard-ci basic-integration/android
  • /wizard-ci basic-integration/angular
  • /wizard-ci basic-integration/astro
Show more apps
  • /wizard-ci basic-integration/django
  • /wizard-ci basic-integration/fastapi
  • /wizard-ci basic-integration/flask
  • /wizard-ci basic-integration/javascript-node
  • /wizard-ci basic-integration/javascript-web
  • /wizard-ci basic-integration/laravel
  • /wizard-ci basic-integration/next-js
  • /wizard-ci basic-integration/nuxt
  • /wizard-ci basic-integration/python
  • /wizard-ci basic-integration/rails
  • /wizard-ci basic-integration/react-native
  • /wizard-ci basic-integration/react-router
  • /wizard-ci basic-integration/sveltekit
  • /wizard-ci basic-integration/swift
  • /wizard-ci basic-integration/tanstack-router
  • /wizard-ci basic-integration/tanstack-start
  • /wizard-ci basic-integration/vue
  • /wizard-ci error-tracking-upload-source-maps/android
  • /wizard-ci error-tracking-upload-source-maps/flutter
  • /wizard-ci error-tracking-upload-source-maps/ios
  • /wizard-ci error-tracking-upload-source-maps/next
  • /wizard-ci error-tracking-upload-source-maps/next-no-posthog
  • /wizard-ci error-tracking-upload-source-maps/node-raw
  • /wizard-ci error-tracking-upload-source-maps/node-rollup
  • /wizard-ci error-tracking-upload-source-maps/node-rollup-typescript-plugin
  • /wizard-ci error-tracking-upload-source-maps/node-webpack
  • /wizard-ci error-tracking-upload-source-maps/nuxt-3-6
  • /wizard-ci error-tracking-upload-source-maps/nuxt-4-3
  • /wizard-ci error-tracking-upload-source-maps/react-native
  • /wizard-ci error-tracking-upload-source-maps/react-vite
  • /wizard-ci error-tracking-upload-source-maps/rust
  • /wizard-ci misc/quack-quack
  • /wizard-ci revenue/stripe

Results will be posted here when complete.

@cvolzer3 cvolzer3 marked this pull request as ready for review June 11, 2026 20:37
@cvolzer3 cvolzer3 requested a review from a team June 11, 2026 20:37
@cvolzer3

Copy link
Copy Markdown
Author

Depends on PostHog/posthog#61178

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