@mhosaic/feedback-cli
v0.16.1
Published
CLI to install @mhosaic/feedback into a host app, verify the integration, and drop a guided Claude Code skill (/integrate-feedback) into ~/.claude/skills.
Readme
@mhosaic/feedback-cli
CLI that wires the @mhosaic/feedback widget into a host app. Detects your framework, writes .env.local, updates .gitignore, auto-wraps a Vite + React entry, pings the backend to verify CORS/key/endpoint, and installs the guided integration skill into your global Claude Code skills directory.
npm i -g @mhosaic/feedback-cli@latest
# or, without installing:
npx @mhosaic/feedback-cli@latest <command>Commands
init — set up the widget in this project
mhosaic-feedback init \
--api-key <pk_proj_…> \
--endpoint <https://your-backend.example.com> \
--yes- Installs
@mhosaic/feedbackvia your detected package manager (pnpm / yarn / npm) - Writes
.env.localwithVITE_FEEDBACK_API_KEY=…+VITE_FEEDBACK_ENDPOINT=…(wrapped in markers so re-running is idempotent) - Ensures
.env.localis in.gitignore - For Vite + React entries: auto-wraps
src/main.tsxwith<FeedbackProvider>(marker comments preserved soejectcleans up cleanly)
Flags:
| Flag | Default | Notes |
|---|---|---|
| --api-key <key> | (prompt) | Required if --yes; must start with pk_proj_ |
| --endpoint <url> | http://localhost:8000 | Must be http(s)://; no whitespace |
| --yes, -y | false | Skip prompts; require --api-key |
| --no-install | (install) | Skip npm install (useful in CI) |
| --cwd <dir> | process.cwd() | Operate on a different project root |
Without --yes and --api-key, the CLI prompts interactively.
doctor — local health check
mhosaic-feedback doctorVerifies (read-only):
- A supported framework was detected
.env.localhasVITE_FEEDBACK_API_KEY=….gitignoreignores.env.local<FeedbackProvider>is wired in the entry file
Exits 0 if all pass, 1 otherwise. Run after init or whenever you suspect the integration drifted.
verify — end-to-end backend handshake
mhosaic-feedback verify --origin <dev-origin> [--with-test-report]Reads .env.local, then checks:
- Both env vars present and well-formed
- Endpoint is
http(s)://… - Endpoint resolves and responds
- CORS preflight from
--originsucceeds - (with
--with-test-report) Submits a synthetic[mhosaic-feedback verify]report and prints the resultingreport.id
Use --origin to match your dev server (http://localhost:5173 for Vite, http://localhost:3000 for Next/Remix). The test report path is destructive — it adds one row to the project's report stream. Delete it from /reports in the admin SPA if you don't want the noise.
install-skill — drop the Claude Code skill in ~/.claude/skills/
mhosaic-feedback install-skill [--force] [--dry-run] [--dest <dir>]Copies the bundled integrate-feedback skill into your global Claude Code skills directory. Run once after installing the CLI; the skill is then invokable as /integrate-feedback from any project. Use --force to overwrite existing files (e.g. after upgrading the CLI).
eject — strip the widget out of this project
mhosaic-feedback ejectRemoves the marker-wrapped blocks init added: import + provider wrap in the entry file, and the env var block in .env.local. Won't touch anything outside those markers. To finish:
pnpm remove @mhosaic/feedback # or npm/yarn equivalentThe guided skill
After install-skill, run /integrate-feedback inside Claude Code. The skill branches on operator vs consumer mode and walks you through provisioning a project, generating a public key, and wiring the widget into your specific framework — with explicit checkpoints, framework-aware snippets, and a smoke test that proves the end-to-end path works before declaring done.
Full details: skills/integrate-feedback/SKILL.md in this package, or installed at ~/.claude/skills/integrate-feedback/SKILL.md after install-skill.
Development
pnpm install
pnpm --filter @mhosaic/feedback-cli build # tsup → dist/
pnpm --filter @mhosaic/feedback-cli exec vitest # unit tests
node packages/cli/dist/bin.js <command> # exercise locallyThe skill files at packages/cli/skills/integrate-feedback/ are bundled into the published npm package (files in package.json) and copied to the user's ~/.claude/skills/ by install-skill. Edits to the skill flow through the same npm publish pipeline as the CLI itself.
