Expose hooks configuration through the CLI and SDK

Status Fixed / completed
Maintainer reply ✓ Yes — dicksontsai
Activity 5 comments · opened Jul 25, 2025 · closed Aug 4, 2025
💡 Likely answer: A maintainer (dicksontsai, collaborator) responded on this thread — see the highlighted reply below.

My scenario is to have a custom mode/agent that is forced into using the "container-use" mcp. Currently, I have to add the following to every single project, but I'm much prefer to create a zsh alias that would trigger this mode/agent.

{
  "hooks": {
    "UserPromptSubmit": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "echo \"Remember to always use the mcp__container-use__environment tools!\""
          }
        ]
      }
    ],
    "Stop": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "bun run /Users/johnlindquist/dev/claude-agents/hooks/cc-stop.ts"
          }
        ]
      }
    ]
  }
}

View original on GitHub ↗

5 Comments

dicksontsai collaborator · 1 year ago

At least for the CLI, you can now use the new --settings flag. Any hooks you add to the file provided by the flag will be included.

Example:

 claude --settings settings_session_start.json
johnlindquist · 1 year ago

@dicksontsai sweet! Thank you!

To clarify, this is "additional" settings? So it will still load project/global settings? I would love a way to completely isolate the settings of a session to ignore all other mcps/hooks/etc.

dicksontsai collaborator · 1 year ago

Yes, --settings would be additional, at least for array-like settings fields such as hooks and mcps.

I would love a way to completely isolate the settings of a session to ignore all other mcps/hooks/etc.

We don't have such a feature yet. The closest is the CLAUDE_CONFIG_DIR env var, but that only isolates the home/user settings, not the project settings

johnlindquist · 1 year ago

@dicksontsai Is some sort of "--isolate-settings" feature planned? Should I open an issue?

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.