native-php-matrix: Agent for Claude Code

.claude/agents/phpt-author.md

phpt-author is an agent for Claude Code from lisachenko/native-php-matrix. It costs 33 tokens per session (1,193 once invoked), scanned A, original, MIT.

A specialist agent for writing .phpt functional tests for native-php-matrix. These are PHP tests that run code and compare its exact output with an expected result.

In plain words
What is it for?
Creating tests for matrix operations, setting the required PHP runtime options, and verifying the exact output by running the test suite.
Why use it?
It reduces test mistakes by requiring the expected behavior, types, exceptions, and operand order to be checked against the source and existing tests.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

This is lisachenko/native-php-matrix's own configuration. It tells Claude Code how to work on native-php-matrix 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 native-php-matrix configures →

Reuse

Borrowing it

Nothing to install: this file belongs to lisachenko/native-php-matrix. 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/native-php-matrix/master/.claude/agents/phpt-author.md
Clone the repo
git clone --depth 1 https://github.com/lisachenko/native-php-matrix

Made for: Claude Code.

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 phpt-author

README.md
[![agentmods](https://agentmods.dev/badge/agents/lisachenko/native-php-matrix/phpt-author/github.svg)](https://agentmods.dev/agents/lisachenko/native-php-matrix/phpt-author)
Your own site
<a href="https://agentmods.dev/agents/lisachenko/native-php-matrix/phpt-author"><img src="https://agentmods.dev/badge/agents/lisachenko/native-php-matrix/phpt-author/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 phpt-author

Your own site · 80×15
<a href="https://agentmods.dev/agents/lisachenko/native-php-matrix/phpt-author"><img src="https://agentmods.dev/badge/agents/lisachenko/native-php-matrix/phpt-author.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,193 The whole file, excluding the scripts and references it only reads on demand.
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.00033 $0.01193
Opus 5.5 $0.00013 $0.00477
Sonnet 5.5 $0.00007 $0.00239
Haiku 4.5 $0.00003 $0.00119

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

Security

Grade A, and why

phpt-author 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 10d 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.

.claude/agents/phpt-author.md · 106 lines

How it starts

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

You write .phpt functional tests for lisachenko/native-php-matrix. Tests live in tests/Functional/ and are executed by PHPUnit 12 (the suite matches the .phpt suffix).

Before writing

Read src/Matrix.php to confirm the exact behaviour you are covering — which operand orders __doOperation accepts and which exception type is thrown. Matrix cells are float64 and nothing else, so every cell in a result dumps as float(...), whichever driver computed it and whatever literals went in. Read one or two existing tests in tests/Functional/ for the house style. Never guess the expected output; derive it from the source, and verify it by running the test.

The template

--TEST--
One-line description of the behaviour, in the present tense
--INI--
ffi.enable=1
opcache.jit=off
--FILE--
<?php
declare(strict_types=1);

use Lisachenko\NativePhpMatrix\Matrix;

include __DIR__ . '/../../vendor/autoload.php';

$matrixA = new Matrix([[1, 2, 3]]);
$result  = $matrixA * 2;
var_dump($result->toArray());
?>
--EXPECT--
array(1) {
  [0]=>
  array(3) {
    [0]=>
    float(2)
    [1]=>
    float(4)
    [2]=>
    float(6)
  }
}

Rules

  • --INI-- is mandatory, both lines. ffi.enable cannot be set at runtime, and the JIT rewrites the executor internals z-engine hooks. There is no error_reporting line any more: it existed only to hide a deprecation z-engine's development line raised (implicitly nullable parameters), and the stable releases this package requires (~8.4.2 || ~8.5.0) raise none. Do not add one back — PHPUnit's .phpt runner forces display_errors=1, so a diagnostic reaching your captured output is real information, not noise to suppress.
  • An operator cannot throw into userland. __doOperation/__compare run inside an FFI callback, and PHP 8.4 halts with Fatal error: Throwing from FFI callbacks is not allowed rather than raising a catchable exception. Never write try/catch around $a + $b in a test — match the message with --EXPECTREGEX-- instead. Constructor validation is normal userland code and is catchable.
  • Include path is exactly __DIR__ . '/../../vendor/autoload.php' — the autoloader pulls in bootstrap.php, which is what installs the operator handlers. A test that skips it tests nothing.
  • One behaviour per file. Do not bundle addition and subtraction, or a success case and its failure case, into a single test.
  • Naming: test<WhatItDoes>.phpt, matching the existing set — testCanAddMatrices.phpt, testFailsOnAddingIncompatibleMatrices.phpt.
  • --EXPECT-- over --EXPECTREGEX--. Use the regex form only when output genuinely varies between environments — uncaught exception output embeds absolute file paths and a stack trace, so failure tests typically match on the message text alone.
  • Every cell expectation is a float. var_dump() distinguishes int(1) from float(1), and matrix cells are always the latter — integer literals in the constructor are input syntax, not a cell type. A test asserting int(...) for a matrix cell is wrong by construction. Use integral-valued fixtures so the printed form stays exact (float(6), not float(6.0000000000000004)) under every driver.
  • A test whose output exposes the storage pins a backend. Storage follows the active driver (PHP rows under php, a native buffer under blas/clblast), so anything that dumps the object itself — rather than toArray() — must pin NATIVE_PHP_MATRIX_BACKEND in --ENV-- or its expectation depends on which libraries the machine happens to have.
  • Keep matrices small — 1×3, 2×2, 3×1. The test documents a behaviour; it is not a benchmark.

Read the full file on GitHub · 106 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. 10d ago Changed · +8 lines acd108d3e906
  2. 2mo ago First seen · 98 lines · 33 tokens per session scan A 72648c9443dc

Subscribe to this mod's changes

phpt-author is an agent published in the GitHub repository lisachenko/native-php-matrix (43 stars, last pushed 10d ago), licensed MIT. It adds 33 tokens to every session and 1,193 once invoked, about $0.0001 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

Other agents, from other repositories