Skip to content

Guide · Agent skill

How to use the JPA/Hibernate Patterns agent skill (jpa-patterns)

Updated · written with AI from the project's own documentation and checked against our catalogue data

The jpa-patterns skill is a reference guide that teaches an AI agent the established best practices for JPA and Hibernate, the Java libraries that map Spring Boot code to database tables. After reading this guide you will know how to install the skill, ask for help with natural requests, and check the advice the agent gives you before you apply it. It is written for Java developers working on Spring Boot services who want consistent data-access conventions.

JPA/Hibernate Patternsaffaan-m/ECC · MIT

Quick start

  1. 1Download the ZIP. Download the jpa-patterns ZIP from this page.
  2. 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for personal use, or into your project's .claude/skills/ folder for one project.
  3. 3Or upload in the Claude apps. Open Settings, go to Capabilities, then Skills, and upload the ZIP.
  4. 4Make a natural request. Describe your Spring Boot JPA task in plain language, naming the entity, query or symptom.
  5. 5Review the suggestions. Check pool sizes, indexes and migrations against your workload and metrics before applying them.
  6. 6Verify with tests and logs. Ask for a @DataJpaTest with Testcontainers and enable Hibernate SQL logging to confirm query behavior.

What the jpa-patterns skill makes the agent do

A skill is a folder of instructions that an AI agent loads when a task matches its description. The jpa-patterns skill is a single file, SKILL.md, that covers entity design, relationships, query optimization, transactions, auditing, indexing, pagination, and connection pooling in Spring Boot.

When the skill is active, the agent follows its guidance on tasks such as designing entities and table mappings, defining @OneToMany, @ManyToOne and @ManyToMany relationships, preventing N+1 query problems, choosing fetch strategies and projections, configuring transactions, and tuning HikariCP. The skill contains only instructions and code examples. It does not run any programs itself.

Install the jpa-patterns skill

Download the ZIP for the skill from this page and unzip it. You have two options. For a personal skill available in all your projects, unzip it into ~/.claude/skills/. For a skill that only applies to one project, unzip it into that project's .claude/skills/ folder.

You can also upload the skill in the Claude apps. Open Settings, go to Capabilities, then Skills, and upload the ZIP there.

  • Personal install: ~/.claude/skills/ (available across projects)
  • Project install: .claude/skills/ inside your project folder
  • Claude apps: Settings → Capabilities → Skills, then upload the ZIP

Trigger the skill with natural requests

You do not need a special command. The agent decides to use the skill when your request matches its description, so describe the Spring Boot data-access task in plain language. Mention JPA, Hibernate, Spring Data, entities, queries, pagination, transactions or connection pooling so the match is clear.

Good requests name the specific problem. Include the entity or repository involved and any symptom you see, such as slow pages or many SQL statements in the logs.

  • "Review my MarketEntity mapping and tell me where I should add indexes."
  • "This list endpoint runs one query per row. Show me how to fix the N+1 problem with JPA."
  • "Set up cursor-like pagination for my orders repository in Spring Data JPA."
  • "Suggest HikariCP settings for my Spring Boot service and explain the trade-offs."
  • "Add auditing with createdAt and updatedAt to my entities."

Examples of what the agent produces

The skill includes concrete patterns the agent can adapt to your code. For auditing, it shows an entity annotated with @EntityListeners(AuditingEntityListener.class) and a configuration class that enables auditing with @EnableJpaAuditing.

For relationships, the guide defaults to lazy loading and suggests a JOIN FETCH query when you need a collection. It also recommends DTO projections for read paths instead of loading full entities.

  • Auditing: @CreatedDate and @LastModifiedDate fields with @EnableJpaAuditing enabled.
  • Fetch strategy: lazy by default, avoid EAGER on collections, use JOIN FETCH when needed.
  • Pagination: PageRequest.of with a sort on createdAt, or an id > :lastId condition for cursor-like paging.
  • Connection pool: recommended spring.datasource.hikari properties such as maximum-pool-size=20.
@Configuration @EnableJpaAuditing class JpaConfig {}

What you need before using it

The skill assumes a Java and Spring Boot project that uses JPA or Hibernate. The examples assume Spring Data JPA. For migrations or query tests you need database access, and the guide suggests Testcontainers for tests.

The skill does not run scripts and does not use the network. Everything it provides is text the agent reads and applies to your code.

  • Java and Spring Boot project using JPA/Hibernate
  • Spring Data JPA, since the examples depend on it
  • Database access for migrations and query tests
  • Testcontainers is suggested for tests

Safety notes and review before you apply changes

The skill itself is instructions only, but the advice it gives changes real code and real databases. Pool sizes and index choices depend on your workload, so the values in the guide are starting points, not answers. Check them against your own metrics before deploying.

Do not apply agent suggestions directly to production databases without review. Keep schema changes in migration tools such as Flyway or Liquibase, which the guide recommends over relying on Hibernate auto DDL in production.

  • Treat pool sizes and indexes as starting points and verify them with real metrics.
  • Review generated migrations before running them against any shared database.
  • Ask the agent to show the SQL the query produces, then confirm it in your logs.

Tips for getting better results

Give the agent the entity code and the query or endpoint in question, so it can reason about your actual relationships. To check SQL efficiency, the guide suggests enabling logs with logging.level.org.hibernate.SQL=DEBUG, and logging.level.org.hibernate.orm.jdbc.bind=TRACE to see parameter values.

Ask for a test with @DataJpaTest and Testcontainers when you change a query, so the change is verified against a real database engine.

  • Paste the entity and repository code, not just a description.
  • Ask for both the query and the SQL logs you would expect to see.
  • Ask the agent to explain trade-offs when it recommends a setting.
logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.orm.jdbc.bind=TRACE

What people use it for

  • Reviewing an entity mapping and adding indexes on slug or status columns.
  • Fixing an N+1 query in a list endpoint by using JOIN FETCH or a DTO projection.
  • Adding createdAt and updatedAt auditing to existing entities.
  • Setting up paginated repository methods with sorting in Spring Data JPA.
  • Tuning HikariCP pool settings for an existing Spring Boot service.

Frequently asked questions

How do I install the jpa-patterns agent skill?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder. You can also upload the ZIP in the Claude apps under Settings, then Capabilities, then Skills.

Is the jpa-patterns skill free to use?

The skill is published under the MIT licence, as stated on this page. Check the licence file in the source repository for the full terms before redistributing it.

What do I need to use the jpa-patterns skill?

You need a Java and Spring Boot project that uses JPA or Hibernate, with the examples assuming Spring Data JPA. Database access is needed for migrations and query tests, and Testcontainers is suggested for tests.

Does the jpa-patterns skill run scripts or use the internet?

No. The skill contains only instructions and code examples. It does not run scripts and does not use the network.

Does this skill work for non-Java projects?

No. It is for Java and Spring Boot projects that use JPA or Hibernate, so the patterns do not apply to other stacks.

How is this different from just asking an AI agent about JPA?

The skill gives the agent a fixed set of established JPA and Hibernate conventions to follow, such as lazy loading by default, DTO projections for reads, and Flyway or Liquibase for migrations. Without it, the agent answers from general knowledge, so results may vary between requests.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use jpa-patterns if you build or review Spring Boot services with JPA or Hibernate and want an agent to follow consistent data-access conventions, or if you are tuning slow queries or HikariCP settings. Skip it for non-Java stacks or projects that do not use JPA/Hibernate. Always check pool sizes and index choices against your own metrics before changing a production database.

Download the skill