mirror of
https://github.com/anthropics/claude-code.git
synced 2026-05-21 11:02:41 +00:00
feat: Add accept-with-feedback plugin
Add a new plugin that allows users to approve permission requests while providing guidance to Claude. This addresses the request for an "accept with feedback" option (similar to the existing "reject with feedback" for plans). The plugin includes: - PermissionRequest hook to intercept permission prompts - /accept-feedback command for one-time feedback - /configure-feedback command for persistent rules - Configuration file support for automated feedback rules Users can now provide context like "make sure to add error handling" when approving operations, and Claude receives this as guidance.
This commit is contained in:
63
plugins/accept-with-feedback/commands/accept-feedback.md
Normal file
63
plugins/accept-with-feedback/commands/accept-feedback.md
Normal file
@@ -0,0 +1,63 @@
|
||||
---
|
||||
description: Set feedback to provide when accepting the next permission request
|
||||
argument_name: feedback
|
||||
---
|
||||
|
||||
# Accept with Feedback
|
||||
|
||||
You are helping the user set feedback that will be automatically provided to Claude when the next permission request is approved.
|
||||
|
||||
## What the user wants
|
||||
|
||||
The user wants to approve an upcoming operation but also provide guidance or feedback to Claude. This feedback will:
|
||||
1. Automatically approve the next permission request
|
||||
2. Send the feedback message to Claude as guidance
|
||||
|
||||
## Instructions
|
||||
|
||||
1. Parse the user's feedback from the argument: `$ARGUMENTS`
|
||||
|
||||
2. If feedback was provided, save it for the next permission request:
|
||||
- Create/update the file `~/.claude/pending-accept-feedback.json`
|
||||
- Store the feedback with the current session ID
|
||||
|
||||
3. Confirm to the user that their feedback has been queued
|
||||
|
||||
## Saving the feedback
|
||||
|
||||
Use this Python code to save the pending feedback:
|
||||
|
||||
```python
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
feedback = """$ARGUMENTS"""
|
||||
session_id = os.environ.get("CLAUDE_SESSION_ID", "default")
|
||||
|
||||
pending_file = Path.home() / ".claude" / "pending-accept-feedback.json"
|
||||
pending_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
try:
|
||||
existing = json.loads(pending_file.read_text()) if pending_file.exists() else {}
|
||||
except:
|
||||
existing = {}
|
||||
|
||||
existing[session_id] = {
|
||||
"message": feedback,
|
||||
"one_time": True
|
||||
}
|
||||
|
||||
pending_file.write_text(json.dumps(existing, indent=2))
|
||||
print(f"Feedback queued for next permission request.")
|
||||
```
|
||||
|
||||
## Example usage
|
||||
|
||||
User runs: `/accept-feedback Make sure to add error handling`
|
||||
|
||||
Then when Claude asks for permission to edit a file, the operation is automatically approved and Claude receives the guidance: "Make sure to add error handling"
|
||||
|
||||
## Response
|
||||
|
||||
After saving, confirm: "Your feedback has been queued. The next permission request will be automatically approved, and Claude will receive your guidance."
|
||||
80
plugins/accept-with-feedback/commands/configure-feedback.md
Normal file
80
plugins/accept-with-feedback/commands/configure-feedback.md
Normal file
@@ -0,0 +1,80 @@
|
||||
---
|
||||
description: Configure persistent feedback rules for accept-with-feedback
|
||||
---
|
||||
|
||||
# Configure Accept-with-Feedback Rules
|
||||
|
||||
You are helping the user configure persistent feedback rules that automatically provide guidance to Claude when certain operations are approved.
|
||||
|
||||
## Configuration file location
|
||||
|
||||
Rules are stored in `.claude/accept-feedback.json` in either:
|
||||
- User's home directory (`~/.claude/accept-feedback.json`) for global rules
|
||||
- Project directory (`.claude/accept-feedback.json`) for project-specific rules
|
||||
|
||||
Project rules take precedence over user rules.
|
||||
|
||||
## Configuration format
|
||||
|
||||
```json
|
||||
{
|
||||
"rules": [
|
||||
{
|
||||
"matcher": "Edit|Write",
|
||||
"conditions": {
|
||||
"file_path": ".py"
|
||||
},
|
||||
"feedback": "Ensure all Python code follows PEP 8 style guidelines and includes type hints."
|
||||
},
|
||||
{
|
||||
"matcher": "Bash",
|
||||
"conditions": {
|
||||
"command": "git"
|
||||
},
|
||||
"feedback": "Use conventional commit format for commit messages."
|
||||
},
|
||||
{
|
||||
"matcher": "*",
|
||||
"feedback": "Please explain your reasoning before making changes."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## Rule properties
|
||||
|
||||
- **matcher**: Tool name pattern (e.g., "Edit", "Write|Edit", "*" for all)
|
||||
- **conditions**: Optional key-value pairs to match against tool input
|
||||
- **feedback**: The guidance message to send to Claude when this rule matches
|
||||
|
||||
## Instructions
|
||||
|
||||
1. Ask the user what kind of feedback rules they want to configure
|
||||
2. Help them create appropriate rules based on their needs
|
||||
3. Save the configuration to the appropriate location
|
||||
|
||||
## Common use cases
|
||||
|
||||
1. **Code style guidance**: Provide style guidelines when editing specific file types
|
||||
2. **Git workflow**: Add commit message format requirements for git operations
|
||||
3. **Safety reminders**: Add warnings when working with sensitive files
|
||||
4. **Project conventions**: Enforce project-specific patterns and practices
|
||||
|
||||
## Example interaction
|
||||
|
||||
User: "I want to always remind Claude to add tests when editing Python files"
|
||||
|
||||
You would create:
|
||||
```json
|
||||
{
|
||||
"rules": [
|
||||
{
|
||||
"matcher": "Edit|Write",
|
||||
"conditions": {
|
||||
"file_path": ".py"
|
||||
},
|
||||
"feedback": "Remember to add or update tests for any code changes."
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user