Skip to main content

How To Write Rules for AI Coding Tools - A Practical Guide from Real Projects

Picture of Robert Pudlik, Software Engineer at <a href="https://softwaremill.com/">SoftwareMill</a>

Robert Pudlik

Software Engineer at SoftwareMill
Dec 11, 2025|22 min read
brain_made_with_binary
1If the user requests unit tests, use UnitTestAgent.
2For endpoint work, use EndpointAgent.
3For business logic, use BusinessLogicAgent.
cat_with_yes

1Design a new endpoint for seat reservations
1This is a Cinema Reservation System that allows customers to browse
2movie showings, select seats in auditoriums, and complete bookings.
3The system handles multiple cinemas, each with several auditoriums
4showing different movies at scheduled times.
5
6Customers can view available seats, make reservations,
7and receive booking confirmations.
1- Backend: Kotlin + Spring Boot
2- Database: PostgreSQL with JPA/Hibernate
3- API: REST with OpenAPI/Swagger documentation
4- Testing: Kotest + MockK for unit tests, Testcontainers for integration tests
5- Build: Gradle with Kotlin DSL
1src/main/kotlin/cinema/
2├── api/ # REST controllers and DTOs
3├── domain/ # Domain entities and value objects
4├── application/ # Business logic layer
5├── repositories/ # Data access layer
6└── config/ # Configuration classes
7
8Naming conventions:
9- Controllers end with Controller (e.g., BookingController)
10- Use cases end with UseCase (e.g., CreateBookingUseCase)
11- Repositories end with Repository (e.g., BookingRepository)
1NEVER write comments in code.
2Code should be self-explanatory through clear naming.
3
4NEVER put business logic in controllers or repositories.
5Business logic belongs in the domain layer only.
6
7ALWAYS use meaningful names that reflect the domain language:
8Booking, Showing, Auditorium, Seat,
9not generic names like Item, Record, or Data.
1If the user mentions the library, assume it is already installed and use it.
2Check or install it only if the user explicitly asks.
1I noticed you're not following rule X.
2Do you see any contradictory rules that might be confusing you?
1What rules are currently loaded in your context? Are any of them conflicting?
1Use @self-improve.mdc to create unit test rules.
2Use @unit-test-a.kt and @unit-test-b.kt as examples to infer patterns.
1According to adjustments in this conversation,
2improve @unit-test-rules.mdc to follow the conventions mentioned.

Subscribe to our newsletter and never miss an article