Skip to content

Commit f6722aa

Browse files
sobychackoilayaperumalg
authored andcommitted
Adding sample for Claude Skills with Spring AI
Signed-off-by: Soby Chacko <soby.chacko@broadcom.com>
1 parent 99a5da9 commit f6722aa

23 files changed

Lines changed: 2894 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
wrapperVersion=3.3.4
2+
distributionType=only-script
3+
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.10/apache-maven-3.9.10-bin.zip
Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
# Document Forge
2+
3+
**AI-Powered Document Creation Studio built with Spring AI**
4+
5+
*"Describe it. Download it."*
6+
7+
## Overview
8+
9+
Document Forge is a demo application showcasing [Claude Skills](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/overview) integration with [Spring AI](https://docs.spring.io/spring-ai/reference/2.0-SNAPSHOT/api/chat/anthropic-chat.html#_skills).
10+
Describe documents in natural language and receive real, downloadable files generated by Claude.
11+
12+
### Supported Document Types
13+
14+
| Type | Extension | Description |
15+
|------|-----------|-------------|
16+
| Excel | `.xlsx` | Spreadsheets with data, formulas, and formatting |
17+
| PowerPoint | `.pptx` | Presentations with slides and layouts |
18+
| Word | `.docx` | Documents with formatting and structure |
19+
| PDF | `.pdf` | Portable document format |
20+
21+
## Screenshots
22+
23+
![Main Form](screenshots/01-main-form.png)
24+
*Select document type and describe what you want*
25+
26+
![Generating](screenshots/02-generating.png)
27+
*Claude generates your document using Skills*
28+
29+
![Result](screenshots/03-result.png)
30+
*Download your generated document*
31+
32+
## Quick Start
33+
34+
### Prerequisites
35+
36+
- Java 21+
37+
- Maven 3.9+
38+
- Anthropic API Key
39+
40+
### Run
41+
42+
```bash
43+
export ANTHROPIC_API_KEY=your-api-key-here
44+
./mvnw spring-boot:run
45+
```
46+
47+
Open http://localhost:8080
48+
49+
## Features
50+
51+
- **Natural Language Input** - Describe what you want in plain English
52+
- **Real File Generation** - Get actual downloadable files, not just descriptions
53+
- **Source Document Upload** - Upload PDF, TXT, CSV, JSON, XML, or MD files for Claude to transform
54+
- **Custom Skills Support** - Apply custom branding or formatting via Anthropic custom skills
55+
- **History Sidebar** - View past generations and re-download files
56+
- **Async Generation** - PowerPoint presentations run in the background with completion notifications
57+
58+
## Custom Skills Integration
59+
60+
Document Forge demonstrates combining pre-built Anthropic skills with custom skills.
61+
An example custom skill is included in `custom-skills/watermark/SKILL.md`.
62+
63+
### Setting Up the Custom Skill
64+
65+
1. **Upload the skill to Anthropic:**
66+
67+
```bash
68+
cd custom-skills/watermark
69+
70+
curl -X POST "https://api.anthropic.com/v1/skills" \
71+
-H "x-api-key: $ANTHROPIC_API_KEY" \
72+
-H "anthropic-version: 2023-06-01" \
73+
-H "anthropic-beta: skills-2025-10-02" \
74+
-F "display_title=Document Watermark" \
75+
-F "files[]=@SKILL.md;filename=document-watermark/SKILL.md"
76+
```
77+
78+
2. **Copy the skill ID from the response** (e.g., `skill_01AbCdEfGhIjKlMnOpQrStUv`)
79+
80+
3. **Set the environment variable:**
81+
82+
```bash
83+
export CUSTOM_SKILL_ID=skill_01AbCdEfGhIjKlMnOpQrStUv
84+
```
85+
86+
4. **Run the application** - The "Apply custom branding" checkbox will now appear in the UI
87+
88+
### Without Custom Skills
89+
90+
If `CUSTOM_SKILL_ID` is not set, the application works normally with pre-built skills only.
91+
The custom branding checkbox will not be shown.
92+
93+
See the [Spring AI Custom Skills documentation](https://docs.spring.io/spring-ai/reference/2.0-SNAPSHOT/api/chat/anthropic-chat.html#_custom_skills) for more details.
94+
95+
## Usage Examples
96+
97+
**Excel - Sales Report**
98+
> "Create a sales report for Q4 2024 with monthly revenue, expenses, and profit columns."
99+
100+
**PowerPoint - Pitch Deck**
101+
> "Create a 5-slide presentation for a startup called 'GreenTech' that makes sustainable packaging."
102+
103+
**Word - Cover Letter**
104+
> "Write a professional cover letter for a software engineering position. The candidate has 5 years of experience with Java and Spring Boot."
105+
106+
**PDF - Invoice**
107+
> "Create an invoice for 40 hours of consulting at $150/hour with standard payment terms."
108+
109+
**Transform a Document**
110+
111+
Upload a meeting notes text file and prompt:
112+
> "Create an action items tracker spreadsheet with columns for task, owner, due date, and status."
113+
114+
## Tech Stack
115+
116+
| Layer | Technology |
117+
|-------|------------|
118+
| Backend | Spring Boot 4.0 |
119+
| AI | Spring AI 2.0.0-SNAPSHOT + Anthropic Claude Skills |
120+
| Templates | Thymeleaf |
121+
| Interactivity | HTMX |
122+
| Styling | Tailwind CSS |
123+
124+
## Configuration
125+
126+
```yaml
127+
spring:
128+
ai:
129+
anthropic:
130+
api-key: ${ANTHROPIC_API_KEY}
131+
chat:
132+
options:
133+
model: claude-sonnet-4-5-20250514
134+
```
135+
136+
## How It Works
137+
138+
```
139+
User Prompt → Spring AI → Claude Skills → File Generated → Download
140+
```
141+
142+
1. User selects document type and enters a natural language prompt
143+
2. Spring AI sends the request to Claude with the appropriate skill enabled
144+
3. Optionally, a custom skill is added for branding or formatting
145+
4. Claude generates the actual document file using code execution
146+
5. `SkillsResponseHelper` extracts file IDs from the response
147+
6. Files are downloaded via Anthropic's Files API and served to the user
148+
149+
---
150+
151+
Built with Spring AI.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: document-watermark
3+
description: MANDATORY branding that MUST be added to ALL generated documents - adds ACME CORPORATION header and Document Forge footer
4+
---
5+
6+
# Document Watermark Skill - MANDATORY
7+
8+
## CRITICAL REQUIREMENT
9+
10+
You MUST add the following branding to EVERY document you generate. This is NOT optional.
11+
12+
## Required Elements
13+
14+
### 1. Header (REQUIRED)
15+
Add "ACME CORPORATION" prominently at the top of the document:
16+
- Excel: Cell A1, bold, larger font size (14pt)
17+
- PowerPoint: First slide title, all slides should have "ACME CORPORATION" in header
18+
- Word/PDF: Document header or first line, centered, bold
19+
20+
### 2. Footer (REQUIRED)
21+
Add "Generated by Document Forge | Confidential" at the bottom:
22+
- Excel: Last row of data + 2 rows, or use sheet footer
23+
- PowerPoint: Footer on all slides
24+
- Word/PDF: Document footer, centered
25+
26+
## Verification
27+
Before completing any document generation:
28+
1. Confirm "ACME CORPORATION" appears at the top
29+
2. Confirm "Generated by Document Forge | Confidential" appears at the bottom
30+
3. If either is missing, add them before saving
31+
32+
This branding is MANDATORY for compliance purposes.

0 commit comments

Comments
 (0)