Skip to content

agent-hooks

Agent hooks must be an object with event name keys

From plugin
claudelint
1113 skills13 agents1 command1 hook
Install
$ npx -y skills add pdugan20/claudelint --agent claude-code

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

Agent hooks must be an object with event name keys

Agent definition

agent-hooks.md
description: "Agent hooks must be an object with event name keys"

agent-hooks

<RuleHeader description="Agent hooks must be an object with event name keys" severity="error" :fixable="false" :configurable="false" category="Agents" />

Rule Details

This rule enforces that the `hooks` field in agent markdown frontmatter is a valid object keyed by event names. The supported event names are PreToolUse, PostToolUse, PostToolUseFailure, PermissionRequest, UserPromptSubmit, Notification, Stop, SubagentStart, SubagentStop, PreCompact, SessionStart, SessionEnd, TeammateIdle, and TaskCompleted. Each key maps to an array of hook matchers. Validation is delegated to the AgentFrontmatterSchema.shape.hooks Zod schema. Correctly structured hooks allow the agent framework to register event handlers at runtime.

Incorrect

Hooks defined as an array instead of an object

---
name: build-agent
description: Runs build pipelines
hooks:
  - PreToolUse
  - PostToolUse
---

Hooks defined as a plain string

---
name: build-agent
description: Runs build pipelines
hooks: PreToolUse
---

Correct

Hooks as an object with event name keys

---
name: build-agent
description: Runs build pipelines
hooks:
  PreToolUse:
    - matcher: Bash
      command: echo "pre-check"
---

How To Fix

Reformat the `hooks` field as an object where each key is a valid event name (PreToolUse, PostToolUse, etc.) and each value is an array of hook matcher objects.

Options

This rule does not have any configuration options.

Related Rules

  • [`agent-hooks-invalid-schema`](/rules/agents/agent-hooks-invalid-schema)
  • [`hooks-invalid-event`](/rules/hooks/hooks-invalid-event)

Resources

  • [Rule Implementation](https://github.com/pdugan20/claudelint/blob/main/src/rules/agents/agent-hooks.ts)
  • [Rule Tests](https://github.com/pdugan20/claudelint/blob/main/tests/rules/agents/agent-hooks.test.ts)

Version

Available since: v0.2.0

Read more
Ships withclaudelint

A linter for Claude Code projects. Validates CLAUDE.md files, skills, settings, hooks, MCP servers, plugins, and more.

Get the whole plugin, auto-invoked
Stats
11
Stars
0
Views
0
Forks
Active
Maintenance
TypeScript
Language
MIT
License
2d ago
Last commit
6mo ago
Created

Repo: pdugan20/claudelint