Limitations
This Skills implementation is specific to Anthropic’s Claude models:- Not portable: Skills require Anthropic’s code execution and Files API infrastructure. They won’t work with other providers (OpenAI, Gemini, etc.)
- Anthropic-specific classes: Uses
AnthropicChatOptions,AnthropicSkill,AnthropicSkillsResponseHelper—not Spring AI’s generic interfaces - Model restrictions: Only Claude Sonnet 4, Sonnet 4.5, and Opus 4 support Skills
- File expiration: Generated files expire after 24 hours in Anthropic’s Files API
- Beta feature: Skills API requires beta headers and may evolve
When to Use Anthropic Skills vs. Generic Agent Skills
Spring AI supports two different approaches to Agent Skills: Use Anthropic’s native Skills API when:- You need the pre-built document generation skills (Excel, PowerPoint, Word, PDF)
- You want skills to run in a sandboxed, secure cloud environment
- You need workspace-scoped skills shared across your team
- You’re committed to using Claude models
- You want Anthropic to manage the execution infrastructure
- You need skills that work across multiple LLM providers (OpenAI, Anthropic, Gemini, etc.)
- Your skills need access to local resources, network, or custom packages
- You want skills bundled and versioned with your application code
- You need more control over the execution environment
- Portability and avoiding vendor lock-in are priorities
Why Use Spring AI for Skills
Using Skills via the raw Anthropic API requires several manual steps:- Adding the
code_executiontool to every request (Skills require it) - Including three beta headers:
skills-2025-10-02,code-execution-2025-08-25,files-api-2025-04-14 - Parsing deeply nested JSON responses to find file IDs
- Making separate HTTP calls to download generated files
- Auto-injects the code execution tool - Skills run Python scripts server-side; we add the required tool configuration
- Manages beta headers - All three required headers are added automatically and merge correctly with other features like prompt caching
- Provides type-safe enums -
AnthropicSkill.XLSXinstead of magic strings - Validates at build time - The 8-skill limit is enforced when you build your options, not when the API call fails
- Extracts file IDs -
AnthropicSkillsResponseHelperrecursively searches nested response structures - Integrates Files API - Download generated files with
anthropicApi.downloadFile()
Pre-built Skills
Anthropic provides four pre-built Skills:| Skill | Output |
|---|---|
XLSX | Excel spreadsheets with data, formulas, charts |
PPTX | PowerPoint presentations with slides and layouts |
DOCX | Word documents with formatting |
PDF | PDF reports and documents |
Basic Usage
Enable Skills throughAnthropicChatOptions using the unified skill() method:
Multiple Skills
Enable multiple Skills for complex workflows:skills() convenience method:
ChatClient API
Skills work with Spring AI’s fluent ChatClient:Downloading Generated Files
Generated files live in Anthropic’s Files API for 24 hours. We provideAnthropicSkillsResponseHelper to extract file IDs and AnthropicApi for file operations.
When Claude generates files, the file IDs are embedded in a nested response structure—sometimes 4 levels deep. AnthropicSkillsResponseHelper handles this with a recursive search that finds file IDs at any depth.
Extract and Download
Batch Download
For responses with multiple files:Custom Skills
Custom Skills let you package your own instructions into reusable modules that Claude applies during document generation:- Corporate branding (headers, footers, watermarks, logos)
- Compliance requirements (disclaimers, confidentiality notices)
- Document templates (standard structures, formatting rules)
- Domain expertise (industry terminology, specialized calculations)
SKILL.md files uploaded to your Anthropic workspace. Once uploaded, they’re available to all workspace members and can be combined with any pre-built Skill.
Skill Structure
Every Skill requires aSKILL.md file with YAML frontmatter:
description field tells Claude when to apply the Skill. Be explicit—words like “MANDATORY” and “MUST” help ensure consistent application.
| Field | Requirement |
|---|---|
name | Max 64 chars, lowercase letters, numbers, hyphens only |
description | Max 1024 chars, must be non-empty |
Uploading Custom Skills
Upload Skills using the Anthropic API:files[]= with square brackets, and filename must include a directory matching the name field in your YAML frontmatter.
Response:
id is what you use in Spring AI.
Using Custom Skills
Reference Custom Skills by ID using the unifiedskill() method:
Version Pinning
For production deployments, pin Custom Skills to specific versions:latest (the default) during development.
Example: Document Generation Service
Here’s a complete service that combines pre-built and Custom Skills:Tips for Custom Skills
A few things we noticed building the watermark skill: Emphatic language helped. When we wanted Claude to consistently add the header and footer, phrases like “MANDATORY” and “MUST” made a difference. Your mileage may vary depending on what your skill does. Format-specific instructions. Since custom skills can be combined with any pre-built skill, we included separate instructions for Excel, PowerPoint, Word, and PDF. Verification checklists. Adding a section asking Claude to verify elements were present before completing the document caught cases where instructions might otherwise be missed.Getting Started
Add the Spring AI Anthropic starter:Quick Reference
| Feature | Value |
|---|---|
| Supported models | Claude Sonnet 4, Sonnet 4.5, Opus 4 |
| Skills per request | Maximum 8 |
| File expiration | 24 hours |
| Recommended max-tokens | 4096+ for complex documents |
| Method | Description |
|---|---|
.skill(AnthropicSkill) | Add pre-built Skill (XLSX, PPTX, DOCX, PDF) |
.skill(String) | Add skill by ID or name (auto-detects pre-built vs custom) |
.skill(String, String) | Add skill with pinned version |
.skills(String...) | Add multiple skills at once |
.skills(List<String>) | Add multiple skills from a list |
Sample Application
We’ve created a sample application that lets you exercise all the Anthropic Skills features covered in this post. The application provides a web interface where you can:- Select a document type (Excel, PowerPoint, Word, or PDF) and enter a natural language prompt describing what you want
- Upload source files to transform existing content — for example, convert a text file into a formatted spreadsheet or turn meeting notes into a presentation
- Enable custom branding to see how Custom Skills add headers, footers, and watermarks to generated documents
- Download the results directly through the Files API integration
AnthropicChatOptions, extracting file IDs with AnthropicSkillsResponseHelper, and downloading generated files through AnthropicApi. It also shows async generation for longer-running requests like presentations.
Related: Generic Agent Skills in Spring AI
This post covers Anthropic’s document generation Skills—a provider-specific feature that produces real files (Excel, PowerPoint, Word, PDF). However, Spring AI also provides generic Agent Skills that work across any LLM provider. The Spring AI Agentic Patterns blog series covers these portable patterns:- Agent Skills: Modular folders of instructions and resources that run locally in your environment—define once, use with OpenAI, Anthropic, Gemini, or any supported model
- AskUserQuestionTool: Enables agents to ask clarifying questions during execution, gathering requirements interactively before acting
- TodoWriteTool: Transparent, trackable task management for multi-step agent workflows
- Task Subagents: Spawn specialized subagents for complex, multi-step tasks
Conclusion
Spring AI provides a streamlined integration with Anthropic’s Agent Skills API. The unifiedskill() method works for both pre-built and custom skills, and handles all the complexity of code execution tools, beta headers, and file extraction automatically.
For complete API documentation, see the Spring AI Anthropic Chat reference. For Custom Skill authoring guidance, see Anthropic’s Skills documentation and Skills Cookbook.