Skip to main content

Bekci

See what your coding agent can do without asking you. One command. Read-only. Nothing leaves your machine.

python3 bekci.py audit --card bekci-card.svg

Recording of bekci audit

A real run, recorded with script and rendered by docs/make_demo.py. The 12-second scan is shortened to 2 seconds; the first 25 lines are shown.

Audit: what you get

This is a real run on my machine (3 Dec 2026, last 7 days, Claude Code + Codex, my own rules plus the DevOps pack):

Bekci audit · last 7 days · Claude Code + Codex

Allowed without asking                   1
  too broad                              0
  network access                         0
  can delete                             0
  contain a secret                       0
Shell commands replayed               7565
  Bekci would have asked               123
  Bekci would have denied                6
File and MCP calls replayed           4249
  Bekci would have asked                11
  Bekci would have denied                0
Guard hooks installed (of 2)             2
Unpinned MCP servers                     0

Bekci audit card

The SVG card holds numbers only: no commands, no paths, no secrets. Its renderer accepts integers and nothing else, and a test checks that commands, paths and tokens from the session history never reach it. Share it or keep it.

What audit reads:

  • Allow rules in ~/.claude/settings.json, settings.local.json, the project settings of every project listed in ~/.claude.json, and Codex ~/.codex/rules/*.rules (prefix_rule(... decision="allow")). Each rule is flagged as too broad (any command, or a general-purpose program such as curl:* or python3 *), network, delete, or containing a secret.
  • Settings that skip approval: Claude Code bypassPermissions, Codex approval_policy = "never", danger-full-access, sandbox network access, and an automatic approvals reviewer. These are listed in the terminal.
  • History replay: tool calls from the last N days in ~/.claude/projects/**/*.jsonl (subagents included) and ~/.codex/sessions/**/*.jsonl, run through Bekci's built-in rules and your Markdown rules. The terminal also shows the count per rule.
  • Setup: whether a PreToolUse hook is installed for each tool, and MCP servers launched through npx, uvx, bunx or docker without a pinned version.

Options: --days N (default 7), --card PATH (the only file it writes), --home DIR (audit another home directory). It never writes the decision log and needs no network. Reading Codex config.toml needs Python 3.11+ (tomllib); on older Pythons that part is skipped and the summary says so.

Limits:

  • Replay uses today's rules on past calls. It tells you what Bekci would decide now, not what happened then.
  • Codex records a command only when it runs. Commands blocked before running are recovered from literal exec_command({cmd: "..."}) calls in the session; commands built from variables at run time cannot be replayed.
  • codex exec --ephemeral keeps no session file, so those runs cannot be replayed. If the hook's decision log exists (BEKCI_LOG), the summary prints its ask/deny/warn counts for the same window for comparison.
  • Session formats change between versions. These were checked against the files Claude Code and Codex wrote on 3 Dec 2026.

The hook

Bekci is a small Python PreToolUse safety hook for Claude Code and Codex. It checks shell commands, file access, and supported MCP actions before a tool runs. Built-in protections cover credential files, AI attribution trailers, external actions, and destructive commands. Optional Markdown rules can add deny, ask, or warn decisions; they cannot weaken built-in protections. An active malformed rule fails closed: it produces an ask decision for its event type (or all event types when olay is invalid). Codex converts that ask to deny, like other approval requests.

Requirements

  • Python 3.10 or newer
  • Claude Code or Codex with support for PreToolUse hooks

Install

Clone or copy this directory to a stable location. Configure BEKCI_LOG and BEKCI_KURALLAR if you want the log and rules stored elsewhere. By default, the hook uses bekci.log and bekci-kurallar.md plus bekci-devops.md beside bekci.py.

Claude Code

Add a PreToolUse command hook to your Claude Code settings. Replace /path/to/bekci with the directory where you installed the files:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "python3 -I /path/to/bekci/bekci.py"
          }
        ]
      }
    ]
  }
}

Codex

Add a PreToolUse command hook to ~/.codex/hooks.json (or the hooks file selected by your Codex setup). Replace /path/to/bekci with the install path:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "python3 -I /path/to/bekci/bekci.py"
          }
        ]
      }
    ]
  }
}

The hook reads event JSON from standard input and writes a decision JSON to standard output. Codex has no approval prompt for this hook, so ask decisions are converted to deny.

Additional rule format

Edit bekci-kurallar.md or set BEKCI_KURALLAR to another Markdown file. Each rule uses a heading and four fields:

### block-dangerous-command
- olay: bash
- karar: deny
- desen: `\bexample-command\b`
- mesaj: This command is disabled by local policy.

olay accepts bash, file, yaz, mcp, or all. karar accepts deny, ask, or warn. Add - kapalı to disable a rule. Malformed active rules are reported as ask decisions and logged as kural-hata:<id>; disabled rules remain inactive. Validate the file before installing changes:

python3 -I bekci.py --check [path]

The command prints each malformed rule and exits 1 if any are found, otherwise exits 0.

DevOps rule pack

bekci-devops.md adds 25 rules for kubectl, Helm, Terraform/OpenTofu, Docker, AWS/GCP/Azure CLIs, systemd, databases and git history rewrites. They ask before deletes, production changes, applies, pushes to registries and commands that print cloud tokens; printing Kubernetes secret values is denied. It is on by default together with bekci-kurallar.md. If you set BEKCI_KURALLAR yourself, list every file you want (separated by :):

export BEKCI_KURALLAR=/path/to/bekci/bekci-kurallar.md:/path/to/bekci/bekci-devops.md

A tool name only counts at the start of a command, so mentions in messages are ignored. On 7 days of my own history (about 7,600 shell commands) the pack flagged 3 commands; all three were quoted text, not real runs. Regex rules cannot tell every quote from a command.

Package

The bekci-guard package on PyPI has no dependencies and installs the bekci and bekci-guard commands with both rule files. To run the audit without installing anything (Python 3.10+; reading Codex TOML settings needs 3.11+):

uvx bekci-guard audit

From a checkout:

uvx --from . bekci-guard audit

When installed as a package, set BEKCI_LOG to a path you choose; the default log sits next to bekci.py, inside the package's environment.

Run tests

python3 -I test_bekci.py
python3 -I test_audit.py
python3 -I test_devops.py

Configuration

  • BEKCI_KURALLAR: additional Markdown rules files, separated by :
  • BEKCI_LOG: path for decision logs; logs contain tool and rule identifiers, not command content

License

MIT; see LICENSE.

Metadata

Release files for bekci-guard 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bekci-guard 0.1.0
File Size Uploaded Provenance Actions
bekci_guard-0.1.0.tar.gz 30.4 kB With provenance Details for bekci_guard-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bekci-guard 0.1.0
File Interpreter ABI Platform Actions
bekci_guard-0.1.0-py3-none-any.whl Python 3 none any Details for bekci_guard-0.1.0-py3-none-any.whl

Total release size: 52.3 kB

Release files / bekci_guard-0.1.0.tar.gz

Download URL bekci_guard-0.1.0.tar.gz
Size 30.4 kB
Tags Source
SHA-256 checksum
How to use checksums
959ac0409b411b73d550d55b275d0f1a4f4e15e7a19b9a0049678194ac93c2ff
BLAKE2b-256 checksum
How to use checksums
f628f8d1a2f20d5a2281b5d1b7e0c09d10c1b02e1966731baff08479cbe4942f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Release files / bekci_guard-0.1.0-py3-none-any.whl

Download URL bekci_guard-0.1.0-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f131d435bbb89f049dbac6fdf4803a2d58ab505a9d91ec8571e59b74c48f2724
BLAKE2b-256 checksum
How to use checksums
2bb85cbfd1f17a88ff09236c420fd8eac239abfd038ab625008fe74f704c2c8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

Security for bekci-guard 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bekci_guard-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 3, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page