Skip to main content

Bark notification hooks for Codex, Claude Code, and OpenClaw agents.

Project description

bark-agent-hook

Standalone Bark notification hooks for Codex, Claude Code, and OpenClaw.

Overview

bark-agent-hook is a Python 3.10+ Typer CLI that installs companion hook assets for local coding agents and sends concise Bark notifications when agent lifecycle events need attention or have completed. The package keeps runtime behavior focused on hook execution, plugin installation, and safe notification delivery.

The project includes:

  • bark_agent_hook/: the typed Python package and CLI entry point.
  • plugins/: runtime plugin assets for Codex, Claude Code, and OpenClaw.
  • tests/: CLI and plugin manifest coverage.
  • .github/: issue templates, PR template, CI, Dependabot, and expected repository governance settings.

Install

Install the CLI from PyPI:

pip install bark-agent-hook
bark-agent-hook --help

If you prefer uv-managed command-line tools:

uv tool install bark-agent-hook
bark-agent-hook --help

You can also run the CLI without installing it first:

uvx bark-agent-hook --help
uvx bark-agent-hook hook --runtime codex --event completion --dry-run

For real agent hooks, keep bark-agent-hook installed in PATH. The installed Codex, Claude Code, and OpenClaw plugins invoke bark-agent-hook hook ... when the agent emits lifecycle events.

Plugin Setup

Install all locally available agent plugins after installing the CLI:

bark-agent-hook install

Install one or more specific agents:

bark-agent-hook install --agent codex
bark-agent-hook install --agent claude --agent openclaw

uvx works for plugin setup too, but the hook runtime still needs an installed bark-agent-hook command later:

uvx bark-agent-hook install --agent codex

Uninstall plugin hooks without removing marketplace sources, environment variables, or historical audit logs:

bark-agent-hook uninstall
bark-agent-hook uninstall --agent codex

Upgrade the CLI with your package manager, then run install again to refresh companion plugins:

pip install --upgrade bark-agent-hook
bark-agent-hook install

Runtime Configuration

BARK_DEVICE_KEY is required for real delivery. Missing or empty values skip notification delivery and exit successfully.

Common optional settings:

BARK_SERVER=https://api.day.app
BARK_GROUP={project}
AGENT_BARK_NOTIFY_GROUP_MODE=agent
AGENT_BARK_NOTIFY_HOOK_URL=
AGENT_BARK_NOTIFY_TITLE_TEMPLATE=
AGENT_BARK_NOTIFY_AUDIT_LOG=1
AGENT_BARK_NOTIFY_AUDIT_LOG_FILE=~/.bark-agent-hook/bark-agent-hook.log

The AGENT_BARK_NOTIFY_* variable names are intentionally preserved for compatibility with existing hook configuration.

Notifications are sent with Bark's Markdown field by default. The short body summary is still produced for dry-run output, duplicate detection, audit metadata, and future compatibility fallbacks, but real Bark requests send markdown when available.

The default title is intentionally compact:

{event} - {project}

Use AGENT_BARK_NOTIFY_TITLE_TEMPLATE to override it. Available title values include {agent}, {event}, {project}, {runtime}, {cwd_basename}, {branch}, and {session}.

Use BARK_GROUP as either a fixed Bark group or a group template. Available group values include {agent}, {event}, {project}, {runtime}, {cwd_basename}, {branch}, and {session}. For example, BARK_GROUP={project} groups notifications by project, and BARK_GROUP={project}@{branch} groups them by project and branch. Group and title variables are not URL-encoded.

Hook Commands

These are the commands installed into the companion plugins:

bark-agent-hook hook --runtime codex --event approval_needed --summary-mode extract
bark-agent-hook hook --runtime codex --event attention_needed --summary-mode extract
bark-agent-hook hook --runtime codex --event audit_only --summary-mode extract
bark-agent-hook hook --runtime codex --event completion --summary-mode extract
bark-agent-hook hook --runtime claude --event approval_needed --summary-mode extract
bark-agent-hook hook --runtime claude --event attention_needed --summary-mode extract
bark-agent-hook hook --runtime claude --event audit_only --summary-mode extract
bark-agent-hook hook --runtime claude --event completion --summary-mode extract
bark-agent-hook hook --runtime openclaw --event completion --summary-mode extract

Codex and Claude Code hook payloads are grouped into notification events before delivery. Approval and explicit user-input events map to approval_needed, user-visible attention events such as notifications, elicitations, permission denials, or plan update payloads map to attention_needed, successful stop events map to completion, failures map to failed, and high-volume lifecycle or tool pipeline events map to audit_only.

audit_only events never call Bark; when audit logging is enabled they are recorded with logged_audit_only_event. This keeps prompt submissions, session starts, compact events, and ordinary tool use available for diagnostics without creating notification noise.

Codex app builds may expose plan changes internally as turn/plan/updated, plan_update, or plan_delta rather than as a public plugin hook. bark-agent-hook recognizes those payload names when it receives them, but direct Plan Mode coverage depends on Codex exposing the corresponding public hook event to installed plugins.

Local dry-run check:

printf '%s' '{"session_id":"demo","cwd":"/tmp/demo-project"}' \
  | BARK_DEVICE_KEY=device-key bark-agent-hook hook --runtime codex --event completion --dry-run

Development

This project uses uv, Ruff, mypy, pytest, tox, and pre-commit.

uv sync --group dev
uv run pytest -q
uv run pre-commit run --all-files
uv build

This repository does not maintain generated command docs; bark-agent-hook --help is the command reference.

Testing And Build

Run the focused test suite during normal development:

uv run pytest -q

Run the compatibility matrix before release-sensitive changes:

uv run tox

Build local distributions with:

uv build

Release

The CI workflow validates pull requests and main pushes. Merges to main can create a GitHub release for the current project.version when one does not already exist. Publishing to PyPI uses trusted publishing through the protected pypi GitHub environment.

Manual PyPI publishing is available through the workflow_dispatch path by providing an existing stable x.y.z release tag. The workflow verifies required CI checks for the release commit before publishing.

Branch And Review Policy

The repository uses GitHub Flow:

  • Open or pick an issue before starting work.
  • Branch from main using a scoped branch name such as chore/13-governance-audit-remediation.
  • Keep changes scoped to the issue.
  • Open a PR against main and fill in the repository PR template.
  • Required CI checks and review gates are declared in .github/settings.yml and should be verified on GitHub.

Documentation

Project documentation lives under docs/:

  • docs/decisions/: architecture and governance decisions.
  • docs/design/: user-facing behavior and design notes.
  • docs/tech/: implementation notes and technical references.
  • docs/release/: release and publishing notes.
  • docs/postmortems/: incident and regression write-ups.

Ownership

CODEOWNERS assigns repository-wide ownership to @qsoyq. Security reporting instructions live in SECURITY.md, and contribution workflow details live in CONTRIBUTING.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bark_agent_hook-0.1.6.tar.gz (98.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bark_agent_hook-0.1.6-py3-none-any.whl (30.3 kB view details)

Uploaded Python 3

File details

Details for the file bark_agent_hook-0.1.6.tar.gz.

File metadata

  • Download URL: bark_agent_hook-0.1.6.tar.gz
  • Upload date:
  • Size: 98.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bark_agent_hook-0.1.6.tar.gz
Algorithm Hash digest
SHA256 ee24ec16053d1e2b3f44099d5575b13c1d5d48f151f056980f1231e2a2bedc80
MD5 513f5c22149c33145aca7a3887089032
BLAKE2b-256 70fea858f6541c570279168b3c54ed58d3af58a5fb01397cf966274f2956f25d

See more details on using hashes here.

File details

Details for the file bark_agent_hook-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: bark_agent_hook-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 30.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for bark_agent_hook-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 120afc5c2a4d81b6cddcc6ddcf403aa4324526da6d84c178adc99f68738faf8c
MD5 1e1cdc54d2fd65c64c85a8454d80e326
BLAKE2b-256 d20f9791c60603fbc84a8f4fe68cfcf636fcb70ec7636360de911e56f8a8b0ff

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page