session-orchestrator — хук для Claude Code и Codex
session-orchestrator — хук для Claude Code и Codex, который структурирует сессию агента: планирование, поэтапное выполнение, контроль качества и закрытие с трекингом задач.
MIT ★ 1 596 обновлён 2026-10-29
.claude/settings.jsonЧто делает session-orchestrator
Хук работает на Claude Code и Codex, поставляется в составе плагина session-orchestrator от hashgraph-online. Он перехватывает события жизненного цикла сессии и навешивает на каждое из них цепочку .mjs-скриптов, которые выполняются синхронно через run-node.sh (или codex-win.cjs на Windows).
При старте сессии on-session-start.mjs выводит меню команд — /session, /plan, /discovery, /evolve — и инициализирует состояние. На PreToolUse по каждому вызову Bash последовательно проходят семь хранителей: pre-bash-destructive-guard.mjs блокирует опасные операции, pre-bash-staging-fence.mjs ограничивает запись за пределы стейджинга, pre-bash-memory-propose-audit.mjs аудирует предложения в память, pre-bash-sessions-ledger-guard.mjs ведёт журнал сессий, pre-tool-state-md-path-guard.mjs следит за путями к файлам состояния, pre-bash-issue-budget.mjs контролирует бюджет задач, enforce-commands.mjs проверяет допустимость команды. После выполнения Bash post-bash-write-verify.mjs подтверждает запись, а loop-guard.mjs срабатывает на любой инструмент и прерывает зацикливание агента.
Интеграция с GitLab и GitHub позволяет закрывать задачи прямо из сессии. Таймаут каждого хука — 5 секунд. Установка сводится к правке .claude/settings.json: хуки регистрируются там вручную.
Какие задачи решает
- заблокировать деструктивные
Bash-команды до их выполнения - не дать агенту зациклиться на одном инструменте
- вести журнал задач и закрывать GitHub/GitLab-ишью из сессии
- ограничить запись файлов за пределами стейджинг-зоны
- восстановить контекст после
compactилиresumeбез потери плана
Примеры запросов агенту
- Начни сессию по задаче из нашего трекера:
/session feature - Создай план для новой фичи:
/plan new - Запусти анализ кодовой базы:
/evolve analyze
Как установить session-orchestrator
Вручную: положить файлы
.claude/settings.jsonБлок hooks: событие (PreToolUse, PostToolUse, Stop…) → команда. Личные — ~/.claude/settings.json
По шагам, с командами для каждой платформы: Хуки Claude Code: что это, где настраивать и как запретить опасную команду
Вопросы о session-orchestrator
Как установить session-orchestrator в Claude Code?
Добавьте записи хуков в .claude/settings.json вручную — точная структура описана в README плагина в репозитории hashgraph-online/awesome-codex-plugins.
Что делает хук session-orchestrator?
Он перехватывает события SessionStart, PreToolUse, PostToolUse, Stop и SubagentStop, запускает цепочку скриптов для защиты от деструктивных команд, зацикливания и выхода за границы стейджинга, а также ведёт журнал сессий и интегрируется с GitHub и GitLab для трекинга задач.
Работает ли session-orchestrator на Windows?
Да. На Windows каждый хук использует codex-win.cjs вместо run-node.sh, остальная логика та же.
Исходный текст
hooks-codex.json · MIT
Hooks bundle shipped with the session-orchestrator plugin for Claude Code.
Session orchestration for Claude Code, Codex, and Cursor IDE — structured planning, wave-based execution, VCS integration (GitLab + GitHub), quality gates, and clean session close-out with issue tracking.
Triggers on: PreToolUse, PostToolUse, SessionStart, Stop, SubagentStop.
```json
{
"description": "Synchronous Codex hooks for payload-compatible Session Orchestrator handlers.",
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact",
"hooks": [
{
"type": "command",
"command": "echo '🎯 Session Orchestrator v5.16.0 — /session [housekeeping|feature|deep] | /plan [new|feature|retro] | /discovery [scope] | /evolve [analyze|review|list]'",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"console.log('🎯 Session Orchestrator v5.16.0 — /session [housekeeping|feature|deep] | /plan [new|feature|retro] | /discovery [scope] | /evolve [analyze|review|list]')\"",
"async": false
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/on-session-start.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" on-session-start.mjs",
"timeout": 5
}
]
}
],
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/pre-bash-destructive-guard.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" pre-bash-destructive-guard.mjs",
"timeout": 5
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/pre-bash-staging-fence.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" pre-bash-staging-fence.mjs",
"timeout": 5
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/pre-bash-memory-propose-audit.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" pre-bash-memory-propose-audit.mjs",
"timeout": 5
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/pre-bash-sessions-ledger-guard.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" pre-bash-sessions-ledger-guard.mjs",
"timeout": 5
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/pre-tool-state-md-path-guard.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" pre-tool-state-md-path-guard.mjs",
"timeout": 5
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/pre-bash-issue-budget.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" pre-bash-issue-budget.mjs",
"timeout": 5
},
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/enforce-commands.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" enforce-commands.mjs",
"timeout": 5
}
]
}
],
"PostToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/post-bash-write-verify.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" post-bash-write-verify.mjs",
"timeout": 5
}
]
},
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/loop-guard.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" loop-guard.mjs",
"timeout": 5
}
]
}
],
"SubagentStart": [],
"SubagentStop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/on-stop.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" on-stop.mjs",
"timeout": 5
}
]
}
],
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "SO_PLATFORM=codex CODEX_PLUGIN_ROOT=\"${PLUGIN_ROOT}\" sh \"${PLUGIN_ROOT}/hooks/run-node.sh\" \"${PLUGIN_ROOT}/hooks/on-stop.mjs\"",
"commandWindows": "set NoDefaultCurrentDirectoryInExePath=1&& node -e \"require(require('path').join(require('path').isAbsolute(process.env.PLUGIN_ROOT||'')?process.env.PLUGIN_ROOT:process.exit(1),'hooks','codex-win.cjs'))\" on-stop.mjs",
"timeout": 5
}
]
}
]
}
}
```
© hashgraph-online · MIT · hashgraph-online/awesome-codex-plugins