Skip to contentllms.txt

Factory Droid — Hooks

File format
JSON
Discovery path
.factory/settings.json
Syllago install method
JSON merge
Symlink support
No
Config file
.factory/settings.json
Handler types
command

Hook events

Canonical EventNative NameCategory
after_tool_executePostToolUseTool
agent_stopStopLifecycle
before_compactPreCompactContext
before_promptUserPromptSubmitLifecycle
before_tool_executePreToolUseTool
session_endSessionEndLifecycle
session_startSessionStartLifecycle
subagent_startSubagentStartLifecycle
subagent_stopSubagentStopLifecycle

Features

How each feature converts to syllago's canonical format. See format conversion for what these statuses mean.

Fields

Native frontmatter or config fields this provider exposes. The first column is the provider's own field name; the canonical key column links to syllago's cross-provider equivalent.

Provider fieldConversionCanonical keySummary
hooksTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →JSON config under top-level hooks key; each event maps to an array of matcher objects, each with a matcher string and a hooks array of {type: command, command: string, timeout?: number} entries.
PreCompactTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →Fires before context compaction, allowing hooks to inject memory or state into the compaction prompt to preserve important context.

Other features

Behaviors, conventions, and capabilities that aren't tied to a single named field — things like path-based activation, discovery rules, and lifecycle behavior.

FeatureConversionSummary
async_executionTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →Matching hooks for the same event execute concurrently (in parallel); deduplication consolidates identical commands automatically
context_injectionTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →additionalContext field in PostToolUse, UserPromptSubmit, and SessionStart hook output injects information into the agent session; systemMessage field in JSON output provides session-level injection
decision_controlTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →PreToolUse hooks return JSON with allow/deny/ask decision field; exit code 2 blocks with stderr fed back to Droid; non-zero non-2 shows stderr to user as non-blocking error
Hook EventsTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →Nine hook events: PreToolUse (block/allow/ask/modify input), PostToolUse (block with reasoning/add context), UserPromptSubmit (block or add context), Stop (block stopping), SubagentStop (block stopping), PreCompact (inject memory), SessionStart (add context), SessionEnd (cleanup), Notification (custom alerts).
Hook Exit Code BehaviorTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →Exit code 0 = success (stdout shown in transcript, or adds context for UserPromptSubmit/SessionStart); exit code 2 = blocking error (stderr fed back to Droid); other non-zero = non-blocking error (stderr shown to user). JSON output fields: continue, stopReason, suppressOutput, systemMessage, plus event-specific fields (allow/deny/ask/updatedInput for PreToolUse; block/additionalContext for PostToolUse and UserPromptSubmit; block for Stop/SubagentStop; additionalContext for SessionStart).
hook_scopesTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →Four scopes documented: user-level (~/.factory/settings.json), project-level (.factory/settings.json), local-uncommitted (.factory/settings.local.json), and enterprise managed policies
input_modificationTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →PreToolUse hooks return updatedInput in JSON output to modify tool parameters before execution
json_io_protocolTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →Hooks receive JSON via stdin containing session_id, transcript_path, cwd, permission_mode, hook_event_name, and event-specific fields; hooks return JSON output with continue, stopReason, suppressOutput, systemMessage, and event-specific fields
matcher_patternsTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →PreToolUse and PostToolUse hooks use matcher strings supporting exact tool names, regex patterns (Edit|Create, Notebook.*), MCP tool patterns (mcp__<server>__<tool>), and wildcard (*) to match all tools
permission_controlTranslatedConversion type: TranslatedActively mapped to the target provider’s equivalent field during conversion.Learn more →PreToolUse hooks return allow, deny, or ask in the JSON decision field to bypass, block, or escalate tool permission decisions
Hook Execution DetailsNot portableConversion type: Not portableUnique to this provider — can’t be carried across providers.Learn more →Default timeout is 60 seconds per command (configurable via timeout field). Matching hooks for the same event run concurrently. Identical commands are automatically deduplicated. Plugin hooks via plugins/[name]/hooks/hooks.json use ${DROID_PLUGIN_ROOT} env var and merge with user configurations.
Hook Input: JSON stdin and Environment VariablesNot portableConversion type: Not portableUnique to this provider — can’t be carried across providers.Learn more →Hooks receive full JSON context via stdin (session_id, transcript_path, cwd, permission_mode, hook_event_name, plus event-specific tool data). Environment variables available include FACTORY_PROJECT_DIR (project root) and standard shell environment.
Hook Scope FilesNot portableConversion type: Not portableUnique to this provider — can’t be carried across providers.Learn more →Hooks live in scoped settings files: ~/.factory/settings.json (user-level), .factory/settings.json (project-level), .factory/settings.local.json (local uncommitted), plus enterprise managed policies.
MCP Tool Hook MatchersNot portableConversion type: Not portableUnique to this provider — can’t be carried across providers.Learn more →MCP tools follow the naming pattern mcp__<server>__<tool> and can be matched with regex patterns in PreToolUse/PostToolUse matchers (e.g., mcp__memory__.* for all memory server tools, mcp__.*__write.* for write operations across all MCP servers).

Sources

Source
https://docs.factory.ai/cli/configuration/hooks-guide
https://docs.factory.ai/reference/hooks-reference