Skip to content

Migrate Factory Hooks

Goal: move legacy PromptScript-owned hooks without overwriting unrelated Factory settings.

Before

.factory/settings.json:

{
"theme": "dark",
"hooks": {
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "prs hook pre-edit # promptscript-generated:pre-edit"
}
]
}
]
}
}

Preview

Terminal window
prs compile --dry-run

PromptScript plans migration only when .factory/hooks.json is absent and legacy ownership is unambiguous.

After

.factory/settings.json keeps unrelated settings:

{
"theme": "dark"
}

.factory/hooks.json receives canonical hooks. The file is keyed directly by event name, without the hooks wrapper that settings.json uses:

{
"PreToolUse": [
{
"hooks": [
{
"type": "command",
"command": "prs hook pre-edit # promptscript-generated:pre-edit"
}
]
}
]
}

PromptScript 1.27 and earlier wrapped hooks.json in a hooks key, which droid does not read. The next prs compile or prs hooks install factory rewrites such a file in the bare shape.

Safety Rules

  • Unknown events abort migration.
  • Malformed entries abort migration.
  • Mixed PromptScript and user ownership aborts migration.
  • No partial write occurs after failed preflight.
  • --no-migrate-factory-hooks leaves legacy file unchanged and reports PS4002.

Apply only after reviewing dry-run:

Terminal window
prs compile

See AI Tool Hooks for installer behavior and cleanup.