Guest User

force @agent-plan

a guest
Oct 27th, 2025
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1.  
  2.  
  3. # .claude/settings.json
  4.  
  5. ```
  6. {
  7. "hooks": {
  8. "UserPromptSubmit": [
  9. {
  10. "hooks": [
  11. {
  12. "type": "command",
  13. "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/prepend_plan_agent.py"
  14. }
  15. ]
  16. }
  17. ]
  18. }
  19. }
  20. ```
  21.  
  22.  
  23. # .claude/hooks/prepend_plan_agent.py
  24.  
  25. ```
  26. #!/usr/bin/env python3
  27. import json
  28. import sys
  29.  
  30. try:
  31. # Read the JSON data passed from Claude Code via stdin
  32. input_data = json.load(sys.stdin)
  33.  
  34. # Check if the current permission mode is 'plan'
  35. if input_data.get("permission_mode") == "plan":
  36. original_prompt = input_data.get("prompt", "")
  37.  
  38. # Important: Only add the prefix if the user hasn't already typed it.
  39. # This prevents a double-trigger like "@agent-Plan @agent-Plan ..."
  40. if not original_prompt.strip().lower().startswith("@agent-plan"):
  41. # Prepend the built-in agent trigger to the user's prompt
  42. updated_prompt = f"@agent-Plan {original_prompt}"
  43.  
  44. # Construct the JSON output to update the prompt
  45. output = {
  46. "hookSpecificOutput": {
  47. "hookEventName": "UserPromptSubmit",
  48. "updatedPrompt": updated_prompt
  49. }
  50. }
  51.  
  52. # Print the JSON to stdout for Claude Code to process
  53. print(json.dumps(output))
  54.  
  55. except (json.JSONDecodeError, KeyError):
  56. # Fail silently, allowing the original prompt to go through if there's an error
  57. pass
  58.  
  59. # Always exit with code 0 to indicate success
  60. sys.exit(0)
  61.  
  62. ```
Advertisement
Add Comment
Please, Sign In to add comment