Index
hooks
Git hook actions for AXM lifecycle hooks.
Provides BranchDeleteHook, CreateBranchHook, CommitPhaseHook,
MergeSquashHook, PreflightHook, WorktreeAddHook, WorktreeRemoveHook,
PushHook, CreatePRHook, and AwaitMergeHook,
auto-discovered by HookRegistry via the axm.hooks
entry-point group.
AwaitMergeHook
dataclass
Poll a PR until merged or timeout.
Reads pr_number (or pr_url) from context and polls
gh pr view --json state every 30 seconds. Times out after
10 minutes by default.
Source code in packages/axm-git/src/axm_git/hooks/await_merge.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary (must contain
|
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/await_merge.py
BranchDeleteHook
dataclass
Delete a branch by name.
Branch name priority:
branchparam (direct override)branchcontext key
Skips gracefully when disabled or when the working directory is not a git repository.
Source code in packages/axm-git/src/axm_git/hooks/branch_delete.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary. |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/branch_delete.py
CommitPhaseHook
dataclass
Commit all changes with message [axm] {phase_name}.
Reads phase_name from context. An optional
message_format can be provided via params
(default "[axm] {phase}"). Skips gracefully when
there is nothing to commit or no git repository.
When from_outputs=True is passed in params, reads
commit_spec from context instead: {message, body?, files}.
Only the listed files are staged (no git add -A).
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | |
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary. |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/commit_phase.py
CreateBranchHook
dataclass
Create a session branch.
Branch name priority:
branchparam (direct override)ticket_id+ticket_titleparams →branch_name_from_ticket(){prefix}/{session_id}(legacy fallback)
Skips gracefully when the working directory is not a git repository.
Source code in packages/axm-git/src/axm_git/hooks/create_branch.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary (must contain |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/create_branch.py
CreatePRHook
dataclass
Create a GitHub PR with auto-merge squash.
Reads branch, commit_spec, and ticket_id from context.
Runs gh pr create followed by gh pr merge --auto --squash.
Skips gracefully when gh is not installed.
Source code in packages/axm-git/src/axm_git/hooks/create_pr.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary. |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/create_pr.py
MergeSquashHook
dataclass
Merge session branch back to main with squash.
Branch name priority: branch param > context["branch"]
{prefix}/{session_id}fallback.
Commit message priority: message param >
[AXM] {protocol_name}: {session_id} fallback.
Source code in packages/axm-git/src/axm_git/hooks/merge_squash.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary (must contain
|
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/merge_squash.py
PreflightHook
dataclass
Report working-tree status and diff as a pre-hook.
Designed for injection into protocol briefings via
inject_result + inline: true.
params:
path — project root (default ".").
diff_lines — max diff lines (default 200, 0 to disable).
Source code in packages/axm-git/src/axm_git/hooks/preflight.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary. |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/preflight.py
PushHook
dataclass
Push the current branch to origin -u.
Reads branch from context (or detects it from HEAD).
Skips gracefully when the working directory is not a git repository.
Source code in packages/axm-git/src/axm_git/hooks/push.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary. |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/push.py
WorktreeAddHook
dataclass
Create a worktree + branch for a ticket.
Reads ticket_id, ticket_title, ticket_labels, and
repo_path from context. The worktree is placed under
/tmp/axm-worktrees/<ticket_id>/.
Skips gracefully when the working directory is not a git repository or the worktree already exists.
Source code in packages/axm-git/src/axm_git/hooks/worktree_add.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context dictionary. |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult with |
Source code in packages/axm-git/src/axm_git/hooks/worktree_add.py
WorktreeRemoveHook
dataclass
Remove a worktree after merge.
Reads worktree_path and repo_path from context.
Uses git worktree remove --force to handle dirty worktrees.
Skips gracefully when the path doesn't exist or isn't a git repo.
Source code in packages/axm-git/src/axm_git/hooks/worktree_remove.py
execute(context, **params)
Execute the hook action.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
context
|
dict[str, Any]
|
Session context (must contain |
required |
**params
|
Any
|
Optional |
{}
|
Returns:
| Type | Description |
|---|---|
HookResult
|
HookResult on success. |