pattern-stack/codegen-patterns/jobs
Claude Code and agent skill by pattern-stack/codegen-patterns
- community
Checking that the SKILL.md file is still in the repository.
Load when authoring a `@JobHandler` class, kicking off a background job from a use case, or configuring job pools in a project that ran `codegen subsystem install jobs`. Triggers include `@JobHandler`, `JobContext`, `ctx.step` / `ctx.spawnChild`, injecting `JOB_ORCHESTRATOR` / `JOB_RUN_SERVICE`, registering `JobsDomainModule` / `JobWorkerModule`, and editing the `jobs:` block in `codegen.config.yaml`.
Install
npx vskill@latest install pattern-stack/codegen-patterns/jobsSKILL.md
The same SKILL.md was published earlier as pattern-stack/codegen-patterns/jobs.
Jobs
Durable background work runs on `@pattern-stack/jobs` (JOBS-3). A job is a value you declare in code (defineJob): a key, a zod input and output, and its steps in order. A run is one durable execution, stored in your app's Postgres; a step is one recorded stage, so a resumed run never redoes a finished step. The executor runs in your process (or in src/worker.ts), sweeps for open runs, and leases each one, so two replicas never advance one run at once.
The engine's full contract ships with the package: node_modules/@pattern-stack/jobs/JOBS_CONTRACT.md. This skill covers the app side codegen generates.
Where things are
| Thing | Where | |
|---|---|---|
| Your jobs | export const x = defineJob(...) in any file under <backend_src>/jobs/ | |
| The job registry | <generated>/jobs.ts — every defineJob export there, regenerated by codegen entity new | |
| The host module | JobsEngineModule.forRoot(...) in the generated SUBSYSTEM_MODULES | |
| Pools and executor knobs | the jobs: block of codegen.config.yaml, generated into <generated>/app-config.ts | |
| The tables | the package's seven job_run* tables, re-exported by your schema barrel for migrations | |
| Event triggers | jobTriggers('<key>', [...]) beside the job — see the bridge skill |
Routing table
| For this task | Read | |
|---|---|---|
| Declaring a job, its steps, starting it, tenancy, YAML jobs | handler-authoring.md | |
Pools (limiters), worker_mode, the standalone worker, collisions and ordering | pools-and-ordering.md |
Non-obvious rules
- A job is registered by being exported from a file under
<backend_src>/jobs/. Runcodegen entity newafter
adding one; the generated jobs.ts lists it. Two exports with the same name are a generation error.
- Start runs with `JobStarter` (
start(key, input, opts, tx?)), injected by class into the service whose
operation starts the job: a job starter is a port, and a port belongs to a service, never to a use case (codegen's ADR-049). A workflow that starts a job calls that service method. Pass tx to create the run in your transaction: it commits with your writes, and the executor's sweep picks it up after the commit.
- A step names its pool as a limiter:
step({ limiter: 'batch', run }).interactive(20) andbatch(5)
always exist; a step naming a pool the config doesn't declare stops the boot.
- Every value is plain JSON (input, step outputs, item results), at most 1 MB: no
Date,Map, class
instances. Send a time as an ISO string.
- A step's code runs in the run's tenant scope: every entity-repository read and write inside it is scoped to the
run's tenant, as superuser on the user axis. SYSTEM_TENANT (no tenant named) is the null tenant partition.
- A job with no `limits` needs a budget at the start (
budget.maxItems); give public or bridge-started jobs
limits.
- Determinism: a step reads its input and earlier outputs, never the clock or randomness to decide what work to
do; bump version when a step's code changes what an open run would compute.
Do not
- Do not write
@JobHandlerclasses, injectJOB_ORCHESTRATOR, or registerJobsDomainModule/JobWorkerModule:
that subsystem (ADR-022) is gone. docs/MIGRATION-jobs-engine.md in the codegen package maps old to new.
- Do not register
JobsEngineModuleinapp.module.tsby hand;SUBSYSTEM_MODULEScomposes it. - Do not create a table per job. A job's values live in the job tables; domain data goes to its domain's tables,
written by a step.
- Do not reach for a job when the caller waits synchronously on the result — that is a service method, or a use case
when it spans services.
Under target.wiring: pattern-stack (no Nest)
codegen subsystem install jobsvendors the Nest-free entry (@shared/subsystems/jobs/core) and writes no
worker.ts; codegen entity new writes the jobs system (<generated>/jobs-system.ts). Start a run with app.system('jobs').starter.start('<key>', input, opts, tx?); read runs through app.system('jobs').store.
- The executor runs in every process whose
JOBS_WORKERistrue(the default;codegen project settingslists it).
An HTTP or CLI process that only starts runs sets it false, and a worker's open-run sweep takes them. jobs.worker_mode is not read.
- A job factory's dependencies are composition parts:
injected<CrmModule>('crm'),injected<IntegrationsModule>('integrations'),
injected<EventsApi>('events'). The generated jobDeps module provides them, typed by the factory (a wrong part does not compile). A class token is refused: there is no container to resolve it by.
jobs.lease_ttl_msis how long a crashed process's run waits before another process resumes it (default 60 s).- Spec:
docs/specs/J-1.mdin the codegen repo.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingconsumer-skills/jobs/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pattern-stack/codegen-patterns/jobs)