Skip to content

feat(cli): add interactive confirmations for destructive commands#920

Merged
aaight merged 1 commit intodevfrom
feature/interactive-confirm-destructive-commands
Mar 16, 2026
Merged

feat(cli): add interactive confirmations for destructive commands#920
aaight merged 1 commit intodevfrom
feature/interactive-confirm-destructive-commands

Conversation

@aaight
Copy link
Copy Markdown
Collaborator

@aaight aaight commented Mar 16, 2026

Summary

  • Creates src/cli/dashboard/_shared/confirm.ts with a reusable confirm(message, skipFlag) utility that reads y/n from stdin
  • Replaces the hard-error pattern (this.error('Pass --yes to confirm deletion.')) with the interactive prompt in all 4 destructive commands: projects delete, users delete, agents delete, projects credentials-delete
  • Adds 11 unit tests covering all acceptance criteria

What was implemented

  • confirm() utility: Uses Node's built-in readline module — no new dependencies
    • Auto-accepts (skips prompt) when --yes flag is passed
    • Auto-accepts when stdin is not a TTY (process.stdin.isTTY === undefined or false) for CI/script compatibility
    • Otherwise shows <message> [y/N]: prompt and reads user input; exits with code 1 on anything other than y/Y
  • 4 delete commands updated: Each now calls await confirm('<what will be deleted>?', flags.yes) instead of erroring
  • Existing test updated: integration-credentials.test.ts "rejects without --yes flag" updated to reflect new non-TTY auto-accept behavior
  • 11 new unit tests in tests/unit/cli/dashboard/confirm.test.ts covering: yes-flag bypass, non-TTY auto-accept (undefined and false), TTY prompts (y/Y acceptance, n/empty/non-y rejection, prompt format, readline cleanup)

Test plan

  • All 5464 unit tests pass
  • Lint check passes (0 errors)
  • TypeScript type check passes (0 errors)

Card

https://trello.com/c/0m5h19yI/442-as-a-user-i-want-interactive-confirmations-for-destructive-commands-so-that-i-dont-accidentally-delete-resources

🤖 Generated with Claude Code

🕵️ claude-code · claude-sonnet-4-6 · run details

Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

Summary

Clean, well-scoped implementation that replaces the hard-error confirmation pattern with an interactive prompt across all 4 targeted delete commands. The confirm() utility is well-designed, tests are thorough, and CI is green. LGTM.

Notes

  • The confirm() utility correctly handles all three cases: --yes flag bypass, non-TTY auto-accept, and interactive TTY prompt.
  • Using process.exit(1) directly (rather than oclif's this.error()) is the right call here since confirm() is a standalone utility without access to the Command instance.
  • The non-TTY auto-accept behavior is the correct design for CI/scripting compatibility and matches the acceptance criteria.
  • Test coverage is solid — 11 tests covering all branches including edge cases (empty input, case insensitivity, readline cleanup).
  • The existing integration-credentials.test.ts update correctly reflects the new behavior in non-TTY test environments.

Minor observation (not blocking): Two other destructive commands (definitions delete and definitions reset) still use the old this.error('Pass --yes to confirm...') pattern. These are explicitly out of scope per the card, but could be migrated in a follow-up for consistency.

🕵️ claude-code · claude-opus-4-6 · run details

@aaight aaight merged commit 9419f5e into dev Mar 16, 2026
6 checks passed
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.

2 participants