Skip to content

feat(cli): add feedback, the anonymous CLI feedback command#119

Merged
AmanVarshney01 merged 5 commits into
mainfrom
feat/cli-feedback-command
Jul 14, 2026
Merged

feat(cli): add feedback, the anonymous CLI feedback command#119
AmanVarshney01 merged 5 commits into
mainfrom
feat/cli-feedback-command

Conversation

@AmanVarshney01

@AmanVarshney01 AmanVarshney01 commented Jul 14, 2026

Copy link
Copy Markdown
Member

What this adds

prisma-cli feedback sends a message to the Prisma CLI team. It is a top-level command like version: it needs no auth, no workspace, no project, no config, and it never prompts, so it works identically for humans, CI, and agents.

$ prisma-cli feedback "loving the new deploy flow"
feedback → Feedback sent. Thank you!

│  id:        019f5f8b-a108-7000-8457-78598b856156
│  sent as:   anonymous
│  included:  CLI 3.0.0-development, node v24.18.0, darwin arm64

Anonymous by default

Without --email, nothing identifying leaves the machine. This is the entire wire payload:

{
  "message": "loving the new deploy flow",
  "meta": {
    "cliVersion": "3.0.0-development",
    "nodeVersion": "v24.18.0",
    "platform": "darwin",
    "arch": "arm64"
  }
}

The command help discloses exactly that list ("Anonymous unless --email is passed. Every submission includes the CLI version, node version, and OS platform/arch, and nothing else."). The service uses the client IP transiently, in memory, to rate limit; it is never stored, and the spec says so.

--email is the only way to become contactable, validated before anything is sent (shape and the service's 320-char limit):

$ prisma-cli feedback "please add X" --email dev@example.com   # payload gains "email"
$ prisma-cli feedback "please add X" --email not-an-email
✘ Invalid email [USAGE_ERROR]
Fix: Pass a valid address with --email, or drop the flag to stay anonymous.

Agent output

--json returns the standard envelope; id is the service's stored submission id (null when the response has none), email is null when anonymous:

{
  "ok": true,
  "command": "feedback",
  "result": {
    "id": "fb_...",
    "email": null,
    "context": { "cliVersion": "...", "nodeVersion": "...", "platform": "...", "arch": "..." }
  }
}

Failure behavior

Validation happens before any network call and exits 2 as USAGE_ERROR: empty or whitespace-only message, message over 4000 characters, email invalid or over 320 characters. Nothing is sent in those cases.

Delivery problems exit 1 as FEEDBACK_SEND_FAILED and surface the service's own detail:

$ prisma-cli feedback "hello"        # service returned 500
✘ Feedback could not be delivered [FEEDBACK_SEND_FAILED]
Why: The feedback service responded with HTTP 500 (db down).
Fix: Check your network and rerun the command.

Requests time out after 3 seconds, and the timeout covers the body read too: a 201 whose body stalls is a delivery failure, not a fake success, and user cancellation propagates instead of exiting 0. Only a fully received non-JSON 2xx body maps to a null id. PRISMA_CLI_FEEDBACK_URL overrides the endpoint for tests and staging.

Crashes point here (and stop breaking --json)

Unexpected crashes previously wrote plain text even under --json. The outermost boundary now emits the standard envelope with code UNEXPECTED_ERROR, and both output modes advertise the feedback command pre-filled with the failing command and error line:

$ prisma-cli project list            # CLI bug/crash
Unexpected CLI error: ENOENT: no such file or directory, open '...'
More: Re-run with --trace for deeper diagnostics
Tell us what happened: prisma-cli feedback 'project list crashed: ENOENT: ...'
{
  "ok": false,
  "command": "project.list",
  "error": { "code": "UNEXPECTED_ERROR", "domain": "cli", "why": "ENOENT: ..." },
  "nextSteps": ["prisma-cli feedback 'project list crashed: ENOENT: ...'"],
  "nextActions": [
    {
      "kind": "run-command",
      "journey": "recover",
      "label": "Report this crash to the Prisma team",
      "command": "prisma-cli feedback 'project list crashed: ENOENT: ...'"
    }
  ]
}

--quiet suppresses the human hint. Usage errors and expected failures never advertise feedback, so the pointer stays a signal rather than wallpaper. The pre-filled command is shell-escaped and runnable verbatim; a companion PR (prisma/skills#21) teaches the prisma-compute skill to run it.

Where feedback goes

A small Bun server on Prisma Compute in the Prisma DevRel workspace, storing to Prisma Postgres (repo: ~/dev/work/prisma-cli-feedback, app cli-feedback), with the same limits enforced server-side plus per-IP rate limiting and a token-gated admin read endpoint.

Docs (spec-first)

  • command-spec.md: feedback section, top-level command lists (Scope and Global Rules), privacy wording including IP handling, crash-pointer bullet.
  • error-conventions.md: FEEDBACK_SEND_FAILED and UNEXPECTED_ERROR registered with recommended meanings; crash-boundary rule updated.
  • output-conventions.md: feedback added to the pattern mapping.

Testing

  • tests/feedback.test.ts: 10 tests against a real local HTTP server: anonymous payload shape, email inclusion, empty/oversized message, invalid and over-long email (nothing sent in each case), service 5xx, unreachable service, stalled 2xx body (fails at 3s), null id.
  • tests/shell.test.ts: crash-boundary tests for the feedback hint, command labeling, pre-filled report escaping, and the UNEXPECTED_ERROR JSON envelope with its recover action.
  • Manual verification sweeps through the built CLI: 25+ usage cases against a mock service (boundaries, flag parsing edges, failure modes, unicode, wire-payload inspection), a forced real crash in all three output modes, and live sends verified end to end against the production service and database. Full suite: 643 tests pass.

Top-level command that posts a message to the CLI team's feedback
service: anonymous by default, --email opts into being contactable,
and every submission carries only non-PII context (CLI version, node
version, OS platform/arch). No auth, workspace, project, or prompts.
Validation failures are usage errors before any network call; delivery
failures (unreachable, 3s timeout, non-2xx) fail with
FEEDBACK_SEND_FAILED and surface the service's error detail.
PRISMA_CLI_FEEDBACK_URL overrides the endpoint for tests and staging.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Adds a new top-level feedback CLI command with message and optional email inputs. The command validates inputs, submits feedback to a configurable endpoint with environment metadata, handles timeout and service failures, and returns structured results. Human-readable output displays submission details and included context. Documentation, command metadata, integration wiring, and automated tests are added, while a database help assertion is made whitespace-tolerant.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title accurately summarizes the main change: adding the new anonymous CLI feedback command.
Description check ✅ Passed The description is clearly related to the changeset and matches the feedback command and its behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/cli-feedback-command
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/cli-feedback-command

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/product/command-spec.md`:
- Line 443: Update the `prisma-cli feedback` command synopsis in the command
specification to wrap `--email <email>` in brackets, documenting it as optional
while preserving the required message argument.

In `@packages/cli/src/controllers/feedback.ts`:
- Around line 94-108: Update the feedback request flow around the AbortSignal
passed to the request to use a manual AbortController with a timer for
FEEDBACK_TIMEOUT_MS instead of AbortSignal.any(). Ensure the timer aborts the
controller when the timeout expires, preserve propagation of
context.runtime.signal cancellation, and clear the timer after the request
completes so timeout errors still produce the existing TimeoutError detail.

In `@packages/cli/tests/feedback.test.ts`:
- Around line 112-124: Add a feedback CLI test alongside the existing
empty-message test that submits a message exceeding MAX_MESSAGE_LENGTH, asserts
a USAGE_ERROR with exit code 2, and verifies no request is sent to the feedback
service. Reuse the existing startFeedbackService and runFeedbackCli helpers.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: cbe37086-462b-45f7-b124-3620dc5d8578

📥 Commits

Reviewing files that changed from the base of the PR and between 10f6c43 and 4cf4367.

📒 Files selected for processing (9)
  • docs/product/command-spec.md
  • packages/cli/src/cli.ts
  • packages/cli/src/commands/feedback/index.ts
  • packages/cli/src/controllers/feedback.ts
  • packages/cli/src/presenters/feedback.ts
  • packages/cli/src/shell/command-meta.ts
  • packages/cli/src/types/feedback.ts
  • packages/cli/tests/database.test.ts
  • packages/cli/tests/feedback.test.ts

Comment thread docs/product/command-spec.md
Comment thread packages/cli/src/controllers/feedback.ts
Comment thread packages/cli/tests/feedback.test.ts
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026
Do not treat a stalled or cancelled response-body read as success:
only a fully received non-JSON body maps to a null id; timeouts map to
FEEDBACK_SEND_FAILED and runtime cancellation propagates. Mirror the
service's 320-character email limit locally. Disclose the attached
context in the command help, and state in the spec that the service
uses the client IP transiently for rate limiting and never stores it.
Register feedback in the Global Rules top-level list, the output
pattern mapping, and the MVP error-code registry.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/product/error-conventions.md`:
- Line 162: Add a one-line “Recommended meaning” entry for FEEDBACK_SEND_FAILED
in the MVP error-code list, matching the format and placement used by
USAGE_ERROR, AUTH_REQUIRED, and the other codes. Describe the
feedback-submission failure without changing the code name or surrounding
entries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: c1382b71-5ebd-40bb-ad7f-877564322bd6

📥 Commits

Reviewing files that changed from the base of the PR and between ed4be46 and bdc19c3.

📒 Files selected for processing (6)
  • docs/product/command-spec.md
  • docs/product/error-conventions.md
  • docs/product/output-conventions.md
  • packages/cli/src/controllers/feedback.ts
  • packages/cli/src/shell/command-meta.ts
  • packages/cli/tests/feedback.test.ts

Comment thread docs/product/error-conventions.md
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 14, 2026
Crashes no longer break the --json contract: the outermost boundary
emits a standard UNEXPECTED_ERROR envelope whose nextActions carries a
recover run-command pre-filled with the failing command and error line
(prisma-cli feedback "..."). Human crash output ends with the same
hint, suppressed by --quiet. Expected failures and usage errors never
advertise feedback.
@AmanVarshney01

Copy link
Copy Markdown
Member Author

@coderabbitai approve

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved and changes approved.

@AmanVarshney01 AmanVarshney01 merged commit 9e0cdf7 into main Jul 14, 2026
10 checks passed
@AmanVarshney01 AmanVarshney01 deleted the feat/cli-feedback-command branch July 14, 2026 11:47
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