How I Made an AI Agent Write Normal Spring Code

Where does the average application on GitHub come from? If you ask an agent to create a JPA entity or configure Spring Security, it will produce quite working code. The question is only one: for what project?

The models are trained on millions of repositories: student projects, the ubiquitous Petclinic, YouTube tutorials, and by the way, I have tons of my own :D.

But without clear context, the agent outputs an "average GitHub application": everything is syntactically correct, but it doesn't always fit into the existing REAL project. With Lombok or without it? Using @IdClass or @EmbeddedId? Do you prefer Records or classic classes? How are DTOs mapped in your project? The agent doesn't know this, and most of the time it either tries to guess, or starts grepping everything it can and can't.

Prompt engineering helps, but only for a short while. Attaching entity examples and architectural rules every single time is outdated. Integration into the IDE with @ and file selection is already better, but you still have to constantly remember it and write the same thing to the ROBOT over and over again.

Agent mode is not a silver bullet

If you give the agent a full task, it does a great job in simple cases. It correctly added a method to the repository, whipped up a CRUD controller, what a champ.

But then you ask it to implement vet shift scheduling with appointment overlap validation… And that's when the agent goes adrift in the ocean of possible solutions.

Technically the code may be correct, but it just doesn't fit into your architecture and the agreed conventions your team has. It's very hard for the agent to properly fill in the context and truly get to know your project. The easiest thing for it is to fill the gap with that average GitHub code. And that's exactly what it does.

Skills — that's where the real holy grail is!

Skills are permanent instructions that the agent automatically loads when solving specific tasks. Without a Skill, it creates a Spring Data JPA repository "the way it's usually done on the internet". With a Skill, it first checks how this is done specifically in your project, and only then adds its own knowledge. Cool? Cool!

But if you collect Skills from public aggregators (like SkillHub and similar ones), conflicts start very quickly. One Skill prefers one style, another prefers a different one. As a result, you can end up with a fairly large but extremely useless set of skills.

Skills do a great job of conveying conventions and best practices. But they are static. And the project is alive: beans change, the domain model grows, new endpoints for your favorite JSON appear! Here it's best to also give the agent a set of specialized MCPs that can help the agent analyze your Spring application in real time not via grep, but via special tools for entities, DTOs, and so on. As a result, the agent will be able to find out in just a couple of calls:

  • the entity dependency tree,

  • what beans exist and how they are related,

  • what migrations already exist.

Spring Agent Toolkit: Skills + MCP that work together

The team at Amplicode together with experts from Spring AIO have put together Spring Agent Toolkit — a set of Skills and an MCP server that are initially designed to work with each other. Unlike a random set of skills, everything here is tested for compatibility. No conflicts arise between skills. The set is constantly being updated. Skills are connected exactly when they are needed.

Spring MCP (works via the Amplicode plugin for IntelliJ IDEA and OpenIDE) provides the agent with the following tools:

  • list_spring_beans_tool

  • get_entity_details

  • create_migration_script

  • and the ability to run/debug the application

And among the Skills there are:

  • Spring Planning — competent task decomposition taking into account the project architecture. Skill on GitHub

  • Spring Explore — deep project analysis. Skill on GitHub

  • Spring Data JPA – best practices for JPA code generation. Skill on GitHub

  • DTO Creator – DTOs will be exactly the same as the ones you already use in your project. Skill on GitHub

  • CRUD REST Controller – I think you already guessed it. Skill on GitHub

  • Java Debug – currently in development, but it looks like something many people have been wanting. Skill on GitHub

  • and more

How to get started?

Install Spring Skills globally for all detected agents:

npx skills add Amplicode/spring-skills -g

Install only for specific agents (example — Claude Code + Codex + Gemini CLI):

npx skills add Amplicode/spring-skills -g -a claude-code -a codex -a gemini-cli

You can find more detailed instructions here.

The set of Skills is constantly being updated. The current list is in the repository. Feedback and discussions are in the Telegram channels Spring AIO and Amplicode.

Comments

    Also read