Best for
- Use when building batch jobs, ETL pipelines, scheduled imports/exports, or any chunk-oriented bulk processing with Spring Batch.
rrezartprebreza/spring-boot-skills/skills/spring-boot-3/spring-batch/SKILL.md
Use when building batch jobs, ETL pipelines, scheduled imports/exports, or any chunk-oriented bulk processing with Spring Batch. Covers the Spring Batch 5 / Boot 3 builder API, restartability and idempotent job parameters, reader/writer thread-safety, fault tolerance, and chunk transaction boundaries.
Decision brief
Spring Boot 3.x ships Spring Batch 5. The API changed significantly from 4.x — most online examples are wrong. The two rules that break the most agent-generated code:
Compatibility matrix
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/rrezartprebreza/spring-boot-skills --skill "skills/spring-boot-3/spring-batch"Inspect the Agent Skill "spring-batch" from https://github.com/rrezartprebreza/spring-boot-skills/blob/8cabf531ead42483fba97b47228ea3b8414cf9b7/skills/spring-boot-3/spring-batch/SKILL.md at commit 8cabf531ead42483fba97b47228ea3b8414cf9b7. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
chunk(500, txManager) means: read 500 items, process each, hand the list of 500 to the writer, commit one transaction, repeat. The chunk is the unit of restart and the unit of rollback.
A JobInstance is identified by its identifying JobParameters. Launch the same job with the same identifying parameters twice and you get:
Paging readers require a deterministic ORDER BY on a unique column. Without it the DB returns
Returning null silently drops the item from the chunk. That's a feature (filtering) but a footgun if you returned null by accident expecting it to pass through.
In 5.x the writer receives a Chunk, not List:
Permission review
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 91/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 194 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Spring Boot 3.x ships Spring Batch 5. The API changed significantly from 4.x — most online examples are wrong. The two rules that break the most agent-generated code:
@EnableBatchProcessing. Boot auto-configures the JobRepository,
JobLauncher, and transaction manager. Adding @EnableBatchProcessing disables that
auto-configuration and you lose all the wired beans.JobBuilderFactory and StepBuilderFactory are gone. Build jobs and steps with
new JobBuilder(name, jobRepository) / new StepBuilder(name, jobRepository), injecting the
JobRepository and PlatformTransactionManager Boot already created.@Configuration
@RequiredArgsConstructor
public class OrderExportJobConfig {
@Bean
public Job orderExportJob(JobRepository jobRepository, Step exportStep) {
return new JobBuilder("orderExportJob", jobRepository)
.incrementer(new RunIdIncrementer()) // lets the same job be re-run; see "Idempotency"
.start(exportStep)
.build();
}
@Bean
public Step exportStep(JobRepository jobRepository,
PlatformTransactionManager txManager, // Boot's, injected — do NOT new one up
ItemReader<Order> reader,
ItemProcessor<Order, OrderRow> processor,
ItemWriter<OrderRow> writer) {
return new StepBuilder("exportStep", jobRepository)
.<Order, OrderRow>chunk(500, txManager) // chunk size is the commit interval — and a TX boundary
.reader(reader)
.processor(processor)
.writer(writer)
.faultTolerant()
.skip(FlatFileParseException.class)
.skipLimit(50)
.build();
}
}
chunk(500, txManager) means: read 500 items, process each, hand the list of 500 to the writer,
commit one transaction, repeat. The chunk is the unit of restart and the unit of rollback.
A JobInstance is identified by its identifying JobParameters. Launch the same job with the
same identifying parameters twice and you get:
JobInstanceAlreadyCompleteException: A job instance already exists and is complete
This is by design — Batch refuses to re-run completed work. Two ways to handle it:
// Option A — RunIdIncrementer on the job (above) + JobLauncherApplicationRunner bumps run.id each launch.
// Option B — add a unique identifying parameter yourself when launching:
JobParameters params = new JobParametersBuilder()
.addString("status", "COMPLETED") // identifying — part of the instance key
.addLong("run.id", System.currentTimeMillis()) // identifying & unique — makes each run a new instance
.toJobParameters();
Mark a parameter non-identifying with the false flag when it's metadata that shouldn't change
the instance identity (e.g. a request id you log but don't key on):
.addString("requestId", requestId, false) // non-identifying — excluded from the instance key
A failed job, by contrast, is resumed when relaunched with the same parameters — it skips completed steps and restarts the failed step from the last committed chunk. That is the point of the metadata tables. Don't defeat it by always passing a unique parameter if you want resume-on-failure.
@Bean
@StepScope // required: late-binds jobParameters at step execution, not context startup
public JpaPagingItemReader<Order> orderReader(
EntityManagerFactory emf,
@Value("#{jobParameters['status']}") String status) {
return new JpaPagingItemReaderBuilder<Order>()
.name("orderReader")
.entityManagerFactory(emf)
.queryString("SELECT o FROM Order o WHERE o.status = :status ORDER BY o.id") // ORDER BY is MANDATORY
.parameterValues(Map.of("status", OrderStatus.valueOf(status)))
.pageSize(500) // keep pageSize == chunk size
.build();
}
ORDER BY on a unique column. Without it the DB returns
rows in arbitrary order across pages → rows get skipped or processed twice. This is silent
data corruption, not an error.JdbcCursorItemReader is NOT thread-safe. JdbcPagingItemReader / JpaPagingItemReader are
safe for multi-threaded steps. For a non-thread-safe reader in a multi-threaded step, wrap it in
SynchronizedItemStreamReader.status from
PENDING to DONE while the reader pages WHERE status = 'PENDING' ORDER BY id, the result set
shifts under you and pages are missed. Read into a stable snapshot, page by immutable id, or use
a cursor reader.@Component
public class OrderProcessor implements ItemProcessor<Order, OrderRow> {
@Override
public OrderRow process(Order order) {
if (order.getTotal().isZero()) {
return null; // ⚠️ null = FILTER this item; it is NOT written and NOT an error
}
return OrderRow.from(order);
}
}
Returning null silently drops the item from the chunk. That's a feature (filtering) but a footgun
if you returned null by accident expecting it to pass through.
In 5.x the writer receives a Chunk<? extends T>, not List<? extends T>:
@Override
public void write(Chunk<? extends OrderRow> chunk) { // was List<? extends T> in 4.x
repository.saveAll(chunk.getItems());
}
For SQL writes, prefer the batched JDBC writer over per-row saves — it uses one addBatch():
@Bean
public JdbcBatchItemWriter<OrderRow> orderWriter(DataSource dataSource) {
return new JdbcBatchItemWriterBuilder<OrderRow>()
.dataSource(dataSource)
.sql("INSERT INTO order_export (id, total) VALUES (:id, :total)")
.beanMapped()
.build();
}
The writer runs inside the chunk transaction. Never fire emails, publish to Kafka, or call webhooks from a writer — if the chunk rolls back you've already sent it. Bind side effects to the job completion instead (see [[transactional-patterns]] and the listener below).
Boot runs every Job bean on startup by default. For scheduled or on-demand jobs, turn that off
and launch explicitly:
spring:
batch:
job:
enabled: false # don't run jobs on app startup; we trigger them ourselves
jdbc:
initialize-schema: never # manage BATCH_* tables with Flyway in prod (see below)
@Component
@RequiredArgsConstructor
public class OrderExportScheduler {
private final JobLauncher jobLauncher;
private final Job orderExportJob;
@Scheduled(cron = "0 0 2 * * *")
public void runNightly() throws JobExecutionException {
JobParameters params = new JobParametersBuilder()
.addString("status", "COMPLETED")
.addLong("run.id", System.currentTimeMillis())
.toJobParameters();
jobLauncher.run(orderExportJob, params);
}
}
The default JobLauncher is synchronous (SyncTaskExecutor) — jobLauncher.run(...) blocks the
@Scheduled thread until the whole job finishes. For fire-and-forget, configure the launcher with an
async TaskExecutor, or trigger from a request thread only if you accept the block.
Spring Batch needs its BATCH_JOB_INSTANCE, BATCH_JOB_EXECUTION, BATCH_STEP_EXECUTION, … tables.
initialize-schema: always is fine for dev/embedded DBs but don't let Batch DDL your production
database on startup. Set initialize-schema: never and ship the schema as a versioned
[[flyway-migrations]] migration (the canonical DDL lives in org/springframework/batch/core/schema-*.sql
inside spring-batch-core).
@Bean
public Job orderExportJob(JobRepository jobRepository, Step exportStep) {
return new JobBuilder("orderExportJob", jobRepository)
.incrementer(new RunIdIncrementer())
.listener(new JobExecutionListener() {
@Override public void afterJob(JobExecution exec) {
if (exec.getStatus() == BatchStatus.COMPLETED) {
notifier.notifyExportReady(exec.getJobParameters()); // safe: all chunks committed
}
}
})
.start(exportStep)
.build();
}
Spring Batch earns its complexity (metadata tables, restart, chunking) on large, restartable,
auditable bulk jobs. For a quick one-off async task, @Async or a @Scheduled loop is lighter.
For durable background jobs with retry, a job queue is a better fit. Match the tool to the scale.
@EnableBatchProcessing — on Boot 3 it disables auto-config; remove it, just inject JobRepositoryJobBuilderFactory / StepBuilderFactory — removed in Batch 5; use new JobBuilder(name, repo) / new StepBuilder(name, repo).chunk(500) without a transaction manager — Batch 5 requires .chunk(500, txManager)write(List<? extends T> items) — Batch 5 signature is write(Chunk<? extends T> chunk)JobInstanceAlreadyCompleteException — add RunIdIncrementer or a unique identifying paramORDER BY (or a non-unique one) — pages skip/duplicate rows silently; order by a unique columnJdbcCursorItemReader in a multi-threaded step — not thread-safe; use a paging reader or SynchronizedItemStreamReadernull from a processor expecting pass-through — null filters (drops) the itemItemWriter — runs inside the chunk TX; do it in an afterJob listener@StepScope on a reader that reads jobParameters — @Value("#{jobParameters[...]}") only binds in step scopespring.batch.job.enabled=false and launch explicitlyinitialize-schema: always DDL the prod DB — use never + a Flyway migration for the BATCH_* tablesAlternatives
rrezartprebreza/spring-boot-skills
Use when building batch jobs, ETL pipelines, scheduled imports/exports, or any chunk-oriented bulk processing with Spring Batch. Covers the Spring Batch 6 / Boot 4 builder API, resourceless vs JDBC job repositories, restartability and idempotent job parameters, reader/writer thread-safety, fault tolerance, and chunk transaction boundaries.
coreyhaines31/marketingskills
When the user wants to plan, design, or implement an A/B test or experiment, or build a growth experimentation program. Also use when the user mentions "A/B test," "split test," "experiment," "test this change," "variant copy," "multivariate test," "hypothesis," "should I test this," "which version is better," "test two versions," "statistical significance," "how long should I run this test," "growth experiments," "experiment velocity," "experiment backlog," "ICE score," "experimentation program
alirezarezvani/claude-skills
App Store Optimization (ASO) toolkit for researching keywords, analyzing competitor rankings, generating metadata suggestions, and improving app visibility on Apple App Store and Google Play Store. Use when the user asks about ASO, app store rankings, app metadata, app titles and descriptions, app store listings, app visibility, or mobile app marketing on iOS or Android. Supports keyword research and scoring, competitor keyword analysis, metadata optimization, A/B test planning, launch checklist
dotnet/skills
Migrates .NET test projects from VSTest to Microsoft.Testing.Platform (MTP). Use when user asks to "migrate to MTP", "switch from VSTest", "enable Microsoft.Testing.Platform", "use MTP runner", set OutputType=Exe only for test projects in Directory.Build.props, or mentions EnableMSTestRunner, EnableNUnitRunner, or UseMicrosoftTestingPlatformRunner. USE FOR: MTP behavioral differences vs VSTest (exit code 8, zero tests discovered, --ignore-exit-code, TESTINGPLATFORM_EXITCODE_IGNORE); centralizing