Skip to content

Permissions & Lifecycle Hooks

Affer can edit files and run shell commands, so every run uses an explicit permission mode. By default the CLI asks before running shell commands or modifying files outside your approved rules. You can switch to plan mode for read-only inspection, acceptEdits for faster local iteration, or bypassPermissions inside isolated containers and CI runners.

affer permission prompt modal

Mode Behavior
default Prompts before running shell commands and unapproved file writes.
plan Read-only exploration and planning; blocks edits and shell execution.
acceptEdits Auto-approves file edits while still prompting for shell commands.
bypassPermissions Runs tools without interactive prompts. Intended for sandboxed containers and CI.

You can attach shell hooks in affer.json to run custom checks, linters, or policy gates at eight points in the session lifecycle:

  • PreToolUse — runs before a tool executes; can block or modify execution.
  • PostToolUse — runs after a tool finishes (useful for formatting or linting).
  • UserPromptSubmit — runs when a prompt is submitted.
  • Stop — runs when the main agent turn finishes.
  • SubagentStop — runs when a delegated subagent finishes.
  • PreCompact — runs before context compaction.
  • SessionStart — runs when a session opens.
  • SessionEnd — runs when a session closes.