Agentic pattern ยท Prompt chaining

Chain Workflow

A Spring AI command-line app that splits one task into four sequential LLM calls. Each call reads the previous output, so a free-text report becomes a sorted markdown table.

The chain

  1. 01 ExtractPull numeric values and their metrics from the text.
  2. 02 StandardizeConvert values to percentages where possible.
  3. 03 SortOrder the lines by value, descending.
  4. 04 FormatRender the result as a markdown table.

Stack

LanguageJava 17
FrameworkSpring Boot 4.1.1 (non-web command-line runner)
AISpring AI 2.1.0-SNAPSHOT, ChatClient
ModelAnthropic Claude (OpenAI and Ollama starters optional)
Storage, messaging, cloud, DockerNot used
EndpointsNone. The app runs the chain once, prints each step and exits.

Run it

export ANTHROPIC_API_KEY=your-key
./mvnw clean package
./mvnw spring-boot:run

Classes

ApplicationSpring Boot entry point. A CommandLineRunner passes a sample Q3 report to the chain.
ChainWorkflowHolds the four system prompts and loops over them, feeding each response into the next call.