Source Code
agent-client-tutorial/01-create-fileWhat Youβll Build
A Java program that asks an agent to create a file, then verifies the file was created. No Spring Boot required β just plain Java with the AgentClient API.Step 1: Set Up the Project
Create a Maven project with the Claude agent dependency:Step 2: Understand the Code
Three lines do the real work:- Model construction is provider-specific (you import
ClaudeAgentModel) - Client usage is portable (
AgentClient.create()and.run()work with any model) - The goal is a plain English string β describe what, not how
Step 3: Run It
Step 4: Verify
Check thathello.txt was created:
What Just Happened
ClaudeAgentModelfound the Claude CLI on your systemAgentClient.create(model)wrapped it in the portable client API.run(goal)sent your English instruction to the Claude CLI- The CLI created the file, and the response told you it succeeded