About bitrix-background-jobs
bitrix-background-jobs is a reference skill for implementing background work in Bitrix. It helps developers choose among scheduled agents, post-response jobs, Messenger queues, and console commands, while documenting execution context and reliability requirements.
Key features
- 01Guidance for choosing a job mechanism
- 02Scheduled and delayed agent guidance
- 03Post-response job guidance
- 04Messenger queue and retry guidance
- 05Idempotency and execution-context rules
Use cases
- 01Schedule periodic or delayed tasks
- 02Run short work after a response
- 03Process queued messages with retries
- 04Plan a one-off long migration
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ bxmaximum/ bitrix-framework-skills --skill bitrix-background-jobsAfter installing, type/bitrix-background-jobsin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
rules/agents.mdbackground-job.mdmessenger-config.mdmessenger.mdDetails
From the project READMEBackground jobs
Baseline: main 23.0+ · Verified: main 26.800.0
| Task | Read |
|---|---|
| Periodic or delayed task, agents on cron, long agents | rules/agents.md |
| Short tail work after the response | rules/background-job.md |
| Queue: message, receiver, dispatch, retries | rules/messenger.md |
Queue config, brokers, messenger:consume, kernel queues | rules/messenger-config.md |
Pick: schedule → agent (on cron); seconds of work after the response → addBackgroundJob; retries, volume, parallel workers → Messenger (Since main 25.100.300, alpha); one-off long migration → console command (bitrix-console-commands).
Invariants
- Background code has no user context: agents and receivers set
global $USER = null; no$_SESSION/cookies. Pass user/site IDs explicitly. - On hits, agents,
web-mode Messenger andaddBackgroundJob()run after the response is sent, afterOnAfterEpilogandsession_write_close(), with the DB pool forced to master. - Keep job code thin: resolve a service via
ServiceLocator::getInstance()->get()and call it (no constructor DI in agents —bitrix-framework). - Jobs must be idempotent: agents can run twice in parallel, messages can be redelivered.
- Log failures through a PSR-3 logger (
bitrix-logger); remove your agents on module uninstall.
Comments
Markdown supported