Skip to main content
hook CX Codex

nightshift — Claude Code hook: what it does, how to install

nightshift binds Codex work sessions to strict time limits, tracking punch lists, deferred decisions, and run logs.

MIT ★ 1,596 updated 2026-10-29

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/settings.json
Open on GitHub

What nightshift does

The nightshift bundle ties into the agent execution cycle across five triggers: PreToolUse, PostToolUse, UserPromptSubmit, SessionEnd, and Stop. Each event executes dedicated logic. For instance, the hardhat guard runs before tools execute, while clock-out-gate checks status on stop.

Implementations exist for both POSIX platforms and Windows. On Linux or macOS, Claude Code runs shell scripts under hooks/codex/. Windows environments rely on encoded PowerShell commands executed with -ExecutionPolicy Bypass. If PowerShell script execution is restricted on Windows, the gate hooks will fail.

What it helps with

  • enforce time bounds on Codex work sessions
  • maintain a persistent punch list across runs
  • review execution logs after sessions finish
  • track parked decisions without derailing the shift

Example prompts for the agent

  • Start a new Codex shift and list the pending punch list items.
  • Park this architectural decision and trigger session wrap-up.
  • Verify active shift status before invoking external tools.

How to install nightshift

Manually: put the files in place

.claude/settings.json

The hooks block: event (PreToolUse, PostToolUse, Stop…) → command. Personal ones go to ~/.claude/settings.json

Step by step, with commands for each platform: Claude Code hooks: what they are, where to configure them, how to block a risky command

Questions about nightshift

How to install nightshift in Claude Code?

Add the hook definitions to .claude/settings.json. Claude Code will automatically trigger the scripts during tool use and session transitions.

What does nightshift do?

It manages structured, accountable sessions for Codex. The bundle tracks active task lists, records run history, and intercepts agent stops.

Which lifecycle events does nightshift intercept?

The bundle hooks into PreToolUse, PostToolUse, UserPromptSubmit, SessionEnd, and Stop.

Source text

hooks.json · MIT
Hooks bundle shipped with the nightshift plugin for Claude Code.

Accountable, time-bounded Codex shifts with a persistent punch list, parked decisions, and reviewable run history.

Triggers on: PreToolUse, PostToolUse, UserPromptSubmit, SessionEnd, Stop.

```json
{
  "description": "nightshift guards for Codex: the PreToolUse hardhat, the Stop clock-out gate, SessionEnd, the PostToolUse pulse, and the UserPromptSubmit plan-room exit.",
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "*",
        "hooks": [
          {
            "type": "command",
            "command": "\"${PLUGIN_ROOT}/hooks/codex/hardhat.sh\"",
            "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAGgAYQByAGQAaABhAHQALgBwAHMAMQAnACkAIAAtAEgAbwBzAHQATgBhAG0AZQAgAGMAbwBkAGUAeAA7ACAAZQB4AGkAdAAgACQATABBAFMAVABFAFgASQBUAEMATwBEAEUA"
          }
        ]
      }
    ],
    "PostToolUse": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "\"${PLUGIN_ROOT}/hooks/codex/pulse.sh\"",
            "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAHAAdQBsAHMAZQAuAHAAcwAxACcAKQAgAC0ASABvAHMAdABOAGEAbQBlACAAYwBvAGQAZQB4ADsAIABlAHgAaQB0ACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQA="
          }
        ]
      }
    ],
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "\"${PLUGIN_ROOT}/hooks/codex/session-end.sh\"",
            "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAHMAZQBzAHMAaQBvAG4ALQBlAG4AZAAuAHAAcwAxACcAKQAgAC0ASABvAHMAdABOAGEAbQBlACAAYwBvAGQAZQB4ADsAIABlAHgAaQB0ACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQA="
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "\"${PLUGIN_ROOT}/hooks/codex/prompt-submit.sh\"",
            "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAHAAcgBvAG0AcAB0AC0AcwB1AGIAbQBpAHQALgBwAHMAMQAnACkAIAAtAEgAbwBzAHQATgBhAG0AZQAgAGMAbwBkAGUAeAA7ACAAZQB4AGkAdAAgACQATABBAFMAVABFAFgASQBUAEMATwBEAEUA"
          }
        ]
      }
    ],
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "\"${PLUGIN_ROOT}/hooks/codex/clock-out-gate.sh\"",
            "commandWindows": "powershell.exe -NoProfile -NonInteractive -ExecutionPolicy Bypass -EncodedCommand JABFAHIAcgBvAHIAQQBjAHQAaQBvAG4AUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAdABvAHAAJwA7ACAAJABQAHIAbwBnAHIAZQBzAHMAUAByAGUAZgBlAHIAZQBuAGMAZQAgAD0AIAAnAFMAaQBsAGUAbgB0AGwAeQBDAG8AbgB0AGkAbgB1AGUAJwA7ACAAJABpAG4AcAB1AHQAIAB8ACAAJgAgACgASgBvAGkAbgAtAFAAYQB0AGgAIAAtAFAAYQB0AGgAIAAkAGUAbgB2ADoAUABMAFUARwBJAE4AXwBSAE8ATwBUACAALQBDAGgAaQBsAGQAUABhAHQAaAAgACcAaABvAG8AawBzAC8AdwBpAG4AZABvAHcAcwAvAGMAbABvAGMAawAtAG8AdQB0AC0AZwBhAHQAZQAuAHAAcwAxACcAKQAgAC0ASABvAHMAdABOAGEAbQBlACAAYwBvAGQAZQB4ADsAIABlAHgAaQB0ACAAJABMAEEAUwBUAEUAWABJAFQAQwBPAEQARQA="
          }
        ]
      }
    ]
  }
}

```

© Orwa Mahmoud · MIT · hashgraph-online/awesome-codex-plugins

Similar hooks

All hooks for Notes, tasks and projects →

From the same set391

The whole set →
repopilot repopilot takes a repo snapshot at session start and checks it again before the agent stops. If tests, suppressions or CI gates got weaker, the session will not end quietly. CX Codex ★ 1,596repo stars codex-project-autopilot codex-project-autopilot — a hook for Claude Code and Codex that runs a check after every file write or edit. Fires automatically on PostToolUse events. CX Codex ★ 1,596repo stars praxis This hook loads Praxis triage when a session starts or resumes, so the agent can work toward a defined outcome instead of a step list. CX Codex ★ 1,596repo stars off-the-wall The off-the-wall hook quotes your earlier fixes into the prompt before every Codex answer. The model sees what you corrected before and stops repeating the same mistakes. CX Codex ★ 1,596repo stars homie homie checks tool calls, pauses risky actions for approval, and removes secrets from results the model reads. CX Codex ★ 1,596repo stars codex-goal-progress codex-goal-progress is a Claude Code hook that tracks Codex Goals with checklist progress and token usage. It shows goal status in the interface. CX Codex ★ 1,596repo stars espresso espresso triggers scripts on session launch and prompt submission to keep agent outputs brief while preserving evidence. CX Codex ★ 1,596repo stars development-skills This hook routes development work through three tiers, formats file changes, and sends each change to a staff-reviewer subagent. It supports Claude Code and Codex. CX Codex ★ 1,596repo stars

Project sponsors

Companies that keep this analytics open