Workhorse for AI coding agents
Find agent-readable documentation, then integrate one transactional job from enqueue through confirmation.
Workhorse gives an AI coding agent a direct path from documentation discovery to verified application code. Start with the narrowest useful Markdown source, then follow the same integration sequence in TypeScript, Python, or Go.
Read the documentation without an HTML shell
- Fetch
/llms.txtfor a compact map of every documentation page, grouped like the sidebar. - Fetch
/llms-full.txtwhen the task needs the complete documentation corpus in one response. - Append
.mdto a page URL for its Markdown twin, such as/docs/enqueue.md. - When the agent starts from HTML, follow the response's
text/markdownalternate link to the same page's Markdown twin.
Use the per-page twin for focused work because it spends less context. Use /llms-full.txt when a
change crosses several contracts and the agent needs to search them together.
Integrate one job end to end
Install the SDK used by the application:
- TypeScript:
npm install @stablemates/workhorse - Python:
pip install stablemates-workhorse - Go:
go get github.com/stablemates/workhorse/go
Each complete example below opens PostgreSQL, enqueues order.created inside the transaction that
inserts the order, runs a matching worker, and reads the durable result. Production processes call
the worker's continuous run method; these bounded examples use one pass so they can finish.
import { Admin, Pool, Queue, Worker } from "@stablemates/workhorse";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const queue = new Queue(pool);
const client = await pool.connect();
let jobId: string;
try {
await client.query("BEGIN");
await client.query("INSERT INTO orders (id, status) VALUES ($1, $2)", ["order-42", "new"]);
jobId = await queue.enqueue("order.created", { orderId: "order-42" }, {}, client);
await client.query("COMMIT");
} catch (error) {
await client.query("ROLLBACK");
throw error;
} finally {
client.release();
}
const worker = new Worker(queue).handle("order.created", async (payload: { orderId: string }) => ({
processedOrderId: payload.orderId,
}));
await worker.runOnce(); // Production worker processes call worker.run().
const job = await new Admin(pool).getJob(jobId);
console.log(job?.state, job?.result);
await pool.end();The application transaction covers acceptance, so the order and job commit or roll back together. The handler runs later and may run again after a retry, so protect its external effects with an idempotency key, outbox, inbox, or compensation path.
Queue, Worker, and Admin are the TypeScript names, including Admin.getJob for confirmation.
Python keeps the types and uses snake-case methods such as Admin.get_job; Go uses
workhorse.NewQueue, workhorse.NewWorker, and workhorse.NewAdmin, with methods such as
Admin.GetJob.
Next
- Agent workflows — compose durable model, tool, timer, and approval boundaries
- Enqueue a job — understand transaction and routing options
- Workers — run handlers continuously in production
Exact enqueue and transaction semantics: architecture reference.