Skip to content

[Bug] Claude adapter generates invalid hooks JSON from hooks.yaml #36

@Darwinium

Description

@Darwinium

Description

When running an agent with the Claude adapter, gitagent run maps hooks/hooks.yaml to a temporary Claude Code hooks JSON file. The generated JSON has an invalid structure — the hooks array is missing inside each matcher entry.

Error

Settings Error

/private/var/folders/.../gitagent-hooks-26f81911.json
 └ hooks
   ├ PostToolUse
   │ └ 0
   │   └ hooks: Expected array, but received undefined
   └ PreToolUse
     └ 0
       └ hooks: Expected array, but received undefined

Expected

Claude Code expects this format:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          { "type": "command", "command": "echo Done" }
        ]
      }
    ]
  }
}

Source hooks.yaml

hooks:
  on_session_start:
    - script: scripts/on-start.sh
      description: Initialize session context
      timeout: 10
      compliance: false
      fail_open: true
  on_error:
    - script: scripts/on-error.sh
      description: Handle errors and escalate if needed
      timeout: 10
      compliance: false
      fail_open: true

Steps to Reproduce

  1. gitagent init --template full --dir ./my-agent
  2. gitagent run -d ./my-agent

Workaround

Clear hooks: echo "hooks: {}" > hooks/hooks.yaml

Environment

  • gitagent installed via npm install -g @open-gitagent/gitagent
  • Adapter: claude
  • OS: macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions