You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: command filter system for Claude tool use approval (#62)
New command filter security system that intercepts Claude's tool uses (Bash, Edit, Write, Read, Grep, Glob, WebFetch, WebSearch, Task, Skill, NotebookEdit) and evaluates them against configurable allowlist/blocklist patterns before execution
Wildcard pattern matching (* matches any non-slash sequence, ** matches anything including slashes) for flexible rule definitions like bash: npm *, edit: src/**, bash: rm -rf *
In-session approval prompt UI (CommandApprovalPrompt) shown inline when a command needs user approval, with options: Allow once, Allow always (with pattern picker), Block always (with pattern picker), and Deny
Settings > Security panel (SettingsSecurity) for managing allowlist/blocklist patterns, toggling the filter on/off, and setting the default behavior for unlisted commands (ask/allow/block)
Smart pattern suggestions — when approving or blocking, the system generates progressively broader pattern suggestions (e.g., exact command → bash: gcloud compute * → bash: gcloud *)
Blocklist takes priority over allowlist for security; default blocklist includes dangerous patterns like bash: rm -rf *, bash: sudo *, edit: **/.env, write: **/*.key
Persistent rules — "Allow always" and "Block always" choices are persisted to the database and synced back to the renderer settings store via a new settings:updated IPC channel
Abort-safe — pending approvals are auto-denied when a session is aborted, and stale approvals are cleared on session idle/send
Files changed
Area
Files
What
New service
command-filter-service.ts
Core pattern matching engine with evaluateToolUse(), formatCommandString(), generatePatternSuggestions(), and wildcard regex support
Main process
claude-code-implementer.ts
Integrates command filter into canUseTool() hook; adds handleCommandApproval() blocking flow, settings persistence, and handleApprovalReply() IPC handler
IPC
opencode-handlers.ts
New opencode:commandApprovalReply channel for routing approval responses
Preload
index.ts, index.d.ts
Expose commandApprovalReply() API and onSettingsUpdated listener; add CommandApprovalRequest type
New component
CommandApprovalPrompt.tsx
Inline approval prompt with tool-aware icons, pattern picker, and allow/deny/remember actions
New component
SettingsSecurity.tsx
Settings panel with enable toggle, default behavior selector, allowlist/blocklist tabs, pattern add/remove UI, and wildcard docs
Store
useCommandApprovalStore.ts
Zustand store managing pending approval requests per session
Store
useSettingsStore.ts
Added CommandFilterSettings type and default values; listens for settings:updated events
Integration
SessionView.tsx
Handles command.approval_needed stream events, renders CommandApprovalPrompt, clears approvals on idle/abort/send
Settings
SettingsModal.tsx
Added Security tab with Shield icon
Exports
stores/index.ts
Re-exports useCommandApprovalStore and CommandApprovalRequest