z-engine: Instructions file for Codex

AGENTS.md

z-engine AGENTS.md is an instructions file for Codex, OpenCode from lisachenko/z-engine. It costs 5,224 tokens per session, scanned A, original, MIT.

Repository instructions for working safely on z-engine, a PHP extension that uses FFI to access the PHP interpreter's internal memory structures.

In plain words
What is it for?
Use it when developing or testing z-engine to match the branch with its intended PHP version, follow its branch model, and regenerate engine definitions correctly.
Why use it?
PHP's internal structures can differ between minor versions, so using the wrong version can cause crashes or silent memory corruption.

Instructions file for CodexOpenCode

Written for Codex and OpenCode: the file is AGENTS.md.

This is lisachenko/z-engine's own configuration. It tells Codex and OpenCode how to work on z-engine itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything z-engine configures →

Reuse

Borrowing it

Nothing to install: this file belongs to lisachenko/z-engine. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/lisachenko/z-engine/8.4/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/lisachenko/z-engine

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for z-engine AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/lisachenko/z-engine/agents-md/github.svg)](https://agentmods.dev/instructions/lisachenko/z-engine/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/lisachenko/z-engine/agents-md"><img src="https://agentmods.dev/badge/instructions/lisachenko/z-engine/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for z-engine AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/lisachenko/z-engine/agents-md"><img src="https://agentmods.dev/badge/instructions/lisachenko/z-engine/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 5,224 This file is loaded in full into every session.
When invoked 5,224 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.05224 $0.05224
Opus 5.5 $0.02090 $0.02090
Sonnet 5.5 $0.01045 $0.01045
Haiku 4.5 $0.00522 $0.00522

Measured 2mo ago against content hash c16a48ded4fe, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

z-engine AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

AGENTS.md · 365 lines

How it starts

The opening of the file, as written. The whole thing — 365 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Working on z-engine

z-engine reaches into the Zend Engine's own memory through PHP FFI. That makes it uniquely powerful and uniquely fragile: a wrong struct offset or a call against the wrong PHP version does not throw — it corrupts memory and segfaults the interpreter. These rules exist to keep that from happening. They apply to human contributors and automated agents alike.

The one rule that is non-negotiable: version matching

Never run z-engine code or tests against a PHP minor version other than the one the current branch targets. The engine's C structures change between every minor version (zend_class_entry alone changed size in 8.1, 8.3 and 8.4). z-engine reads those structures by offset. Run it on a mismatched version and you are reading and writing the wrong memory — the result is a crash, or worse, silent corruption.

  • master targets the newest supported PHP minor (currently 8.5).
  • Branch 8.4 targets PHP 8.4.
  • Branch 8.0 is the frozen legacy line for PHP 8.0.

Core::init() enforces this at runtime and refuses to boot on the wrong minor. Do not try to defeat that guard.

Branch model

Fixes land on the minimum affected version branch and are merged upward, never cherry-picked downward. The succession is declared in .github/branch-flow.json and automated by .github/workflows/merge-up.yml, which opens a merge-up PR when a version branch is pushed.

8.0 (frozen)      8.4  ──►  master (8.5)

So a bug that exists in both 8.4 and 8.5 is fixed on 8.4, and the cascade carries it into master. A bug that only exists on 8.5 is fixed on master directly. When resolving a merge-up conflict inside include/, do not merge the generated headers textually — regenerate them on the target branch (composer gen-headers) instead.

Generated engine definitions — never hand-edit

Everything under include/<minor>/<os>-<arch>-<ts>/ is generated:

File What it is
engine.h FFI header (structs, functions, globals) sliced from the PHP source
constants.php #define/enum/opcode values, the ground truth for the PHP class constants
layouts.json sizeof/offsetof of every dereferenced struct, from the C compiler
probe.c the generated C probe (kept so a probe-only run can reuse it)

Read the full file on GitHub · 365 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 365 lines · 5,224 tokens per session scan A c16a48ded4fe

Subscribe to this mod's changes

z-engine AGENTS.md is an instructions file published in the GitHub repository lisachenko/z-engine (456 stars, last pushed 25d ago), licensed MIT. It adds 5,224 tokens to every session, about $0.0209 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

z-engine AGENTS.md compared with instructions from other repositories

z-engine AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
z-engine AGENTS.mdlisachenko/z-engineInstructions file45625d agoMITA5,224Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149kyesterdayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195kyesterdayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode