1. Go to this page and download the library: Download tinywan/harness library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
tinywan / harness example snippets
/**
* @desc Quick Start Example
* @author Tinywan(ShaoBo Wan)
* @date 2026/09/01
*/
declare(strict_types=1);
space = '/path/to/project';
// 1. Get corresponding CLI backend (options: claude, codex, copilot, opencode)
$backend = Harness::byName('codex');
// 2. Build task configuration
$job = new Job(
workspace: $workspace,
srcDir: '.',
prompt: 'Implement a function to parse CSV files and write unit tests for it.',
model: 'gpt-5.3-codex',
maxTurns: 20
);
// 3. Run and receive structured event stream in real-time
try {
Runner::run($backend, $job, function (Event $event): void {
// Output formatted log: [thinking], [tool], [text], [result], [rate-limit], [error]
echo $event->format() . "\n";
});
} catch (AccountError $e) {
echo "Account quota / access limit error: " . $e->getMessage() . "\n";
if ($e->resetAt !== null) {
echo "Suggested retry time: " . $e->resetAt->format('Y-m-d H:i:s') . "\n";
}
} catch (\Throwable $e) {
echo "Execution failed: " . $e->getMessage() . "\n";
}
use Harness\Skills\SkillParser;
use Harness\Skills\SkillDelivery;
use Harness\Harness;
use Harness\Job;
use Harness\Runner;
use Harness\Event;
// 1. Parse SKILL.md adhering to the Agent Skills specification
$skill = SkillParser::parse('/path/to/security-review/SKILL.md');
// 2. Select backend and configure job
$backend = Harness::byName('claude');
$job = new Job(
workspace: '/path/to/project',
srcDir: '.',
skillName: $skill->name,
model: 'claude-sonnet-4-6',
outputFile: 'report.json'
);
// 3. Automatically stage the skill and associated dependencies into the backend discovery path
SkillDelivery::stage($backend, $job, $skill);
// 4. Run task
Runner::run($backend, $job, function (Event $event): void {
echo $event->format() . "\n";
});
// Resume context using sessionID captured from a previous run
$resumeJob = new Job(
workspace: '/path/to/project',
srcDir: '.',
resumeSessionID: '01a0626b-cb18-7e31-876b-7d40abe94431',
resumePrompt: 'Please add handling for empty lines and BOM headers to the code just written.',
model: 'gpt-5.3-codex'
);
Runner::run($backend, $resumeJob, function (Event $event): void {
echo $event->format() . "\n";
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.