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
- 01 ExtractPull numeric values and their metrics from the text.
- 02 StandardizeConvert values to percentages where possible.
- 03 SortOrder the lines by value, descending.
- 04 FormatRender the result as a markdown table.
Stack
| Language | Java 17 |
|---|---|
| Framework | Spring Boot 4.1.1 (non-web command-line runner) |
| AI | Spring AI 2.1.0-SNAPSHOT, ChatClient |
| Model | Anthropic Claude (OpenAI and Ollama starters optional) |
| Storage, messaging, cloud, Docker | Not used |
| Endpoints | None. 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
Application | Spring Boot entry point. A CommandLineRunner passes a sample Q3 report to the chain. |
|---|---|
ChainWorkflow | Holds the four system prompts and loops over them, feeding each response into the next call. |