# Codex

Send a Pushbag notification when Codex finishes a turn and give the agent a packaged publishing guide.

Local Codex loads Stop handlers from a trusted project. Use one to send a turn-completion message while you work away from the terminal.

## Install the skill

Complete the [CLI quickstart](/docs) on the machine running Codex. For notifications alone, use a Notifications key granted access to Personal. Install the packaged skill from your project directory:

```sh
pushbag guide pbg-plan --install
pushbag notify "Codex setup check"
```

The project installation writes `.agents/skills/pbg-plan/SKILL.md` under the Git root, or the current directory outside Git. Codex can use this skill when asked to prepare a shareable plan. The installer copies the guide and its accompanying files. It leaves hook registration to you. Confirm the setup check appears in Personal. The hook process needs the same CLI on its PATH and access to the saved profile or `PUSHBAG_API_KEY`.

## Configure completion notifications

Add the following to `.codex/hooks.json`, merging with any existing configuration.

```json title=".codex/hooks.json"
{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "pushbag notify 'Codex turn finished' >/dev/null"
          }
        ]
      }
    ]
  }
}
```

Open the trusted project in Codex. Run `/hooks`, review the Stop command and trust it before testing.

Start a turn in Codex and ask it to summarize a file. When it finishes, check Personal in the dashboard or in the Inbox on your phone. See the [Codex hook reference](https://developers.openai.com/codex/hooks).

## Include the project name

For a project-specific message, replace the handler’s `command` field with this JSON member. These examples use a POSIX shell and a Git worktree:

```json
{
  "command": "root=$(git rev-parse --show-toplevel) && pushbag notify \"Codex finished in ${root##*/}\" >/dev/null"
}
```

## Send a report link instead

For turns that produce a review, have the agent write `review.html` at the project root. Use a Both key granted Personal. Replace the command with a call to a shell script saved in the project:

```json
{
  "command": "sh \"$(git rev-parse --show-toplevel)/.codex/publish-review.sh\""
}
```

```sh title=".codex/publish-review.sh"
root=$(git rev-parse --show-toplevel) || exit 1
report="$root/review.html"
if [ -f "$report" ]; then
  pushbag upload "$report" --private --notify >/dev/null || exit 1
fi
```

The hook publishes once per invocation while the report exists. Move the report after review if later turns should stay quiet. To test, create a small HTML report, finish a turn and open the version link in Personal.

## Troubleshooting

Review the command in `/hooks` after editing it. A project hook needs a trusted project. If notifications appear twice, look for the same handler in your user and project hooks. Run `command -v pushbag` in the environment that launches the agent. If PATH differs from your shell, use the absolute executable path. Run `pushbag config show` and `pushbag whoami` there to check for a missing key or unexpected account. A Notifications key can send the setup message but lacks upload access. For report uploads use a Both key with a grant for the target channel. See [key presets](/docs/keys).

## Packaged skill example

```sh
pushbag upload plan.html --title "<Project>: <topic>" --description "<one line>" --json
```
