Skip to main content
skill CX Codex

magento-cronjob-developer — Claude Code skill: Magento 2 cron jobs

magento-cronjob-developer guides the agent through building Magento 2 cron jobs: the etc/crontab.xml config, the job class, failure handling and debugging.

MIT 165 installs ★ 33 updated 2026-01-24

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add maxnorm/magento2-agent-skills --skill magento-cronjob-developer -a claude-code
Open on GitHub

What magento-cronjob-developer does

This skill covers scheduled work inside Magento 2 modules. The agent starts from requirements and expected load, then writes the etc/crontab.xml config, then the PHP class that does the work. A ready example is included: a default group with a */5 * * * * schedule and a Vendor\Module\Cron\Job class whose constructor takes Psr\Log\LoggerInterface.

Later sections deal with what actually breaks in production. Retries after a failed run. Batching instead of loading a whole table at once. Memory limits. Locks that stop the same job from starting twice. When something misbehaves, the skill points at bin/magento cron:status and bin/magento cron:run for a manual run.

A */5 * * * * schedule with no lock lets two runs of one job sit on top of each other whenever the first is still busy. Decide how to handle that before the code goes in, not after.

What it helps with

  • Register a job in etc/crontab.xml under the right group
  • Write a job class that logs failures and rethrows them
  • Split a large catalog sync into batches that fit memory
  • Trace why a scheduled task never fires
  • Stop two runs of the same job from overlapping

Example prompts for the agent

  • Add a cron job that pulls stock levels from our supplier API every five minutes: config in etc/crontab.xml, class in Vendor\Module\Cron\SyncStock
  • My job never runs. Check bin/magento cron:status and review the config
  • Rework this job to handle records in batches and log the failures

How to install magento-cronjob-developer

1Skills CLI (Vercel)

npx skills add maxnorm/magento2-agent-skills --skill magento-cronjob-developer -a claude-code

2Manually: put the files in place

~/.claude/skills/magento-cronjob-developer/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/magento-cronjob-developer/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about magento-cronjob-developer

How do I install magento-cronjob-developer in Claude Code?

Run npx skills add maxnorm/magento2-agent-skills --skill magento-cronjob-developer -a claude-code. The skill file lands at ~/.claude/skills/magento-cronjob-developer/SKILL.md.

What does magento-cronjob-developer do?

It helps the agent design and write Magento 2 cron jobs: etc/crontab.xml configuration, an execute job class, logging, retries, and debugging with bin/magento cron:run.

Which kinds of jobs can it help build?

Stock and price synchronization, order status updates, data import and export, log cleanup and backups, webhook handling, cache warming, reindexing.

Source text

SKILL.md · MIT
---
name: magento-cronjob-developer
description: Implements scheduled tasks and background processing for Magento 2. Use when creating cron jobs, scheduling automated tasks, implementing background processing, or automating system operations. Masters cron configuration, job scheduling, error handling, and performance optimization.
---

# Magento 2 Cron Job Developer

Expert specialist in creating reliable, efficient scheduled tasks and background processes that automate critical business operations while maintaining system performance and reliability.

## When to Use

- Creating scheduled tasks
- Implementing background processing
- Automating system operations
- Building data synchronization jobs
- Implementing maintenance tasks
- Creating notification systems

## Cron Job Architecture

- **Cron Configuration**: Master crontab.xml configuration and job scheduling
- **Job Classes**: Implement robust job execution classes and error handling
- **Schedule Management**: Design flexible scheduling patterns and intervals
- **Resource Management**: Optimize memory and processing resource usage
- **Dependency Management**: Handle job dependencies and execution order

## Cron Development Process

### 1. Job Planning & Design
- **Requirements Analysis**: Understand business requirements and execution patterns
- **Performance Planning**: Plan for expected load and resource requirements
- **Error Scenarios**: Identify potential failure points and recovery strategies
- **Monitoring Strategy**: Plan logging, alerts, and performance tracking
- **Integration Points**: Design integration with existing systems and processes

### 2. Configuration Setup
- **Crontab Configuration**: Configure job scheduling in `etc/crontab.xml`
- **Group Organization**: Organize jobs into logical groups and categories
- **Schedule Definition**: Define appropriate execution intervals and timing
- **Resource Allocation**: Plan memory limits and execution timeouts
- **Environment Configuration**: Configure for different environments

### 3. Job Implementation
- **Job Class Development**: Create robust job execution classes
- **Business Logic**: Implement core job functionality and operations
- **Data Processing**: Handle data validation, transformation, and storage
- **Error Handling**: Implement comprehensive error handling and logging
- **Progress Tracking**: Create progress monitoring and status reporting

### 4. Testing & Deployment
- **Unit Testing**: Test individual job components and logic
- **Integration Testing**: Test job integration with system components
- **Performance Testing**: Validate job performance under expected load
- **Error Testing**: Test error scenarios and recovery mechanisms
- **Deployment Strategy**: Plan safe deployment and rollback procedures

## Cron Configuration

### crontab.xml Structure
```xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Cron:etc/crontab.xsd">
    <group id="default">
        <job name="vendor_module_job" instance="Vendor\Module\Cron\Job" method="execute">
            <schedule>*/5 * * * *</schedule>
        </job>
    </group>
</config>
```

### Job Class Implementation
```php
<?php

declare(strict_types=1);

namespace Vendor\Module\Cron;

use Psr\Log\LoggerInterface;

class Job
{
    /**
     * @param LoggerInterface $logger
     */
    public function __construct(
        private readonly LoggerInterface $logger
    ) {
    }

    /**
     * Execute cron job
     */
    public function execute(): void
    {
        try {
            // Job logic here
            $this->logger->info('Cron job executed successfully');
        } catch (\Exception $e) {
            $this->logger->error('Cron job failed: ' . $e->getMessage());
            throw $e;
        }
    }
}
```

## Specialized Cron Job Types

### E-commerce Automation
- **Inventory Updates**: Automated stock level synchronization and alerts
- **Price Updates**: Scheduled pricing changes and promotional activations
- **Order Processing**: Automated order status updates and fulfillment
- **Customer Communications**: Automated email campaigns and notifications
- **Report Generation**: Scheduled business reports and analytics

### Data Management Jobs
- **Data Import/Export**: Automated data synchronization with external systems
- **Database Maintenance**: Scheduled cleanup, optimization, and archiving
- **Log Management**: Automated log rotation, cleanup, and archiving
- **Backup Operations**: Scheduled backup creation and validation
- **Cache Management**: Automated cache warming and invalidation

### System Maintenance
- **Performance Monitoring**: Automated system health checks and alerts
- **Security Scans**: Scheduled security audits and vulnerability checks
- **Update Processes**: Automated system and extension updates
- **Cleanup Operations**: Temporary file cleanup and resource optimization
- **Index Management**: Automated reindexing and search optimization

### Integration Jobs
- **API Synchronization**: Scheduled data sync with external APIs
- **Third-party Updates**: Automated integration with external services
- **Webhook Processing**: Background processing of webhook notifications
- **Data Transformation**: Automated data transformation and migration
- **Notification Delivery**: Scheduled notification and alert delivery

## Best Practices

### Performance
- **Batch Processing**: Process data in batches to avoid memory issues
- **Resource Management**: Monitor and limit memory usage
- **Execution Time**: Set appropriate execution timeouts
- **Lock Management**: Prevent job overlap and resource conflicts
- **Optimization**: Optimize queries and data processing

### Reliability
- **Error Handling**: Comprehensive error handling and logging
- **Retry Mechanisms**: Implement retry logic for transient failures
- **Monitoring**: Log job execution and errors
- **Alerting**: Set up alerts for job failures
- **Recovery**: Implement recovery mechanisms for failed jobs

### Security
- **Access Control**: Ensure proper permissions for job execution
- **Data Validation**: Validate all input data
- **Error Messages**: Don't expose sensitive information in error messages
- **Logging**: Log security-relevant events
- **Audit Trail**: Maintain audit trails for critical operations

## Testing

- **Unit Tests**: Test job logic in isolation
- **Integration Tests**: Test job integration with system components
- **Performance Tests**: Validate job performance under load
- **Error Tests**: Test error scenarios and recovery
- **Schedule Tests**: Verify cron schedule configuration

## Monitoring & Debugging

### Logging
```php
$this->logger->info('Job started');
$this->logger->debug('Processing item: ' . $itemId);
$this->logger->error('Job failed: ' . $exception->getMessage());
```

### Cron Status
```bash
# Check cron status
bin/magento cron:status

# Run cron manually
bin/magento cron:run

# Check cron schedule
bin/magento cron:schedule
```

## References

- [Adobe Commerce Cron](https://developer.adobe.com/commerce/php/development/components/cron/)
- [Scheduled Tasks](https://developer.adobe.com/commerce/php/development/components/cron/)

Focus on creating reliable, efficient cron jobs that automate business operations while maintaining system performance and reliability.

© maxnorm · MIT · maxnorm/magento2-agent-skills

Similar skills

All skills for Backend and APIs →

From the same set30

The whole set →
magento-knockout-specialist magento-knockout-specialist guides coding agents in building reactive KnockoutJS UI components and MVVM patterns for Magento 2. CX Codex +1 168installs magento-environment-engineer The magento-environment-engineer skill helps manage Magento 2 across development, staging, production, and testing environments. Use it for server configuration and environment troubleshooting. CX Codex +1 168installs magento-css-specialist magento-css-specialist — a skill for building Magento 2 CSS and LESS, covering responsive themes, component styling, and CSS performance work. CX Codex +1 167installs magento-alpine-specialist magento-alpine-specialist briefs the agent on building reactive Alpine.js components for Magento 2 storefronts, Hyvä included. Handy when a template needs behaviour without a separate JS framework. CX Codex +1 166installs magento-local-environment-specialist magento-local-environment-specialist walks the agent through a local Magento 2 setup: containers, PHP settings, database, cache, step debugging. Also covers breakage after a move to another machine. CX Codex +1 164installs magento-theme-developer The magento-theme-developer skill builds and modifies Magento 2 themes, covering child themes, layout XML, templates, responsive styling, and frontend performance. CX Codex +1 161installs magento-cache-analyst magento-cache-analyst optimizes Magento 2 caching architectures, covering Redis backends, Varnish FPC, ESI tags, and invalidation workflows. CX Codex +1 160installs magento-magewire-specialist The magento-magewire-specialist skill guides agents through building reactive Magewire components for Magento 2. Use it for server-driven interfaces with minimal JavaScript. CX Codex +1 153installs

Project sponsors

Companies that keep this analytics open