In this guide (7 items)
Claude Code Guide
Claude Code Guide
ABSOLUTE REQUIREMENT FOR ALL AI AGENTS: Before generating any code, you MUST read hexagonal-architecture.md, ddd.md, clean-code.md, kotlin-code-style.md or java-code-style.md, observability.md, security.md, and spring-boot.md. Failure to follow the hexagonal architecture patterns produces architecturally invalid code. EVERY class MUST be placed in the correct layer. EVERY dependency MUST point inward (domain ← application ← infrastructure ← bootstrap).
FIRST STEP FOR NEW PROJECTS: verify all resource files exist per resources.md. If missing, generate them FIRST.
Project-agnostic: code samples use placeholder package
com.example.platformand service nameplatform-service. Replace with your project’s actual values when applying patterns.
This file is the index. Concrete step-by-step content lives in the four themed files below.
Themed Files
| File | Scope | LOC |
|---|---|---|
| ccg-domain-and-ports.md | Step 1 (domain model), Step 2 (inbound + outbound ports, command), Step 3 (use case). | ~335 |
| ccg-adapters-and-wiring.md | Step 4 (REST controller, JDBC repository, Kafka consumer/producer, metrics adapter), Step 5 (bootstrap wiring). | ~670 |
| ccg-bugfix-and-testing.md | Bug-fix workflow, unit test patterns (use case), integration test patterns (repository + Testcontainers). | ~155 |
| ccg-reference.md | Common task recipes, anti-patterns, pre-merge checklist, dependency direction, getting started. | ~215 |
Required Reading Order
Before making any changes, read these guides in order:
- hexagonal-architecture.md — Hexagonal architecture, ports, adapters, outbox, chain of responsibility.
- ddd.md — Domain-Driven Design concepts.
- clean-code.md — Clean code principles, transaction patterns.
- kotlin-code-style.md —
fun interface, extension functions,data class. (Kotlin projects) - java-code-style.md — interfaces, static methods,
record. (Java projects) - observability.md — metrics, logging, distributed tracing.
- security.md — AuthN/Z, secrets, validation, audit.
- api-design.md — REST conventions, versioning, error envelope (for endpoints).
- spring-boot.md — Spring Boot integration patterns.
- resources.md — required resource files for each module.
- This guide — feature workflow + bug-fix patterns (themed files above).
Architecture Quick Reference
platform-service/├── domain/ # Pure domain models, zero dependencies│ ├── Organization.kt│ ├── User.kt│ └── support/OutboxMessage.kt│├── application/ # Use cases and ports, depends on domain only│ ├── port/│ │ ├── inbound/ # Entry point contracts│ │ │ └── CreateOrganizationPort.kt│ │ └── outbound/ # Dependency contracts│ │ └── repository/│ │ ├── OrganizationRepositoryPort.kt│ │ └── support/TransactionPort.kt│ │ # NO publisher/ folder — OutboxRepositoryPort + MessagePublisherPort│ │ # + OutboxEventFactory ship in codehuntersio-sdk-event-messaging.│ └── usecase/│ └── CreateOrganizationUseCase.kt│├── infrastructure/│ ├── entry-points/ # Inbound adapters│ │ ├── rest-controller/ # HTTP endpoints│ │ ├── kafka-consumer/ # Message consumers│ │ └── scheduler-task/ # Background jobs│ └── driven-adapters/ # Outbound adapters│ ├── jdbc-repository/ # Database│ ├── kafka-producer/ # Messaging│ ├── redis-cache/ # Caching│ └── metrics-publisher/ # Observability│└── bootstrap/ # Spring Boot wiring ├── MainApplication.kt └── config/ ├── UseCaseConfig.kt ├── JdbcConfig.kt └── KafkaConfig.ktWorkflow Index
Adding a new feature (end-to-end):
- ccg-domain-and-ports.md §Step 1 — domain model (if needed).
- ccg-domain-and-ports.md §Step 2 — inbound + outbound ports + command.
- ccg-domain-and-ports.md §Step 3 — use case implementation.
- ccg-adapters-and-wiring.md §Step 4 — REST / JDBC / Kafka / metrics adapters.
- ccg-adapters-and-wiring.md §Step 5 — bootstrap Spring config.
Fixing a bug:
- ccg-bugfix-and-testing.md — failing test first, then minimal fix.
Writing tests:
- ccg-bugfix-and-testing.md §Testing Patterns — use case (mocked ports) + Testcontainers integration.
- testing.md — full strategy: TDD, Karate, ArchUnit, coverage.
Common smaller tasks (new entity, new repo method, cache, metrics, background job):
Avoiding anti-patterns:
Pre-merge checks:
Dependency Direction Quick Reference
┌───────────────┐│ domain │ ← pure logic, no framework, no I/O└───────▲───────┘ │ depends on┌───────┴───────┐│ application │ ← use cases + ports, depends on domain only└───────▲───────┘ │ depends on┌───────┴───────┐│ infrastructure│ ← adapters, frameworks, I/O, implements ports└───────▲───────┘ │ depends on┌───────┴───────┐│ bootstrap │ ← Spring Boot wiring, all module deps└───────────────┘Never reverse. Domain MUST NOT import Spring, JPA, Kafka, Jackson, anything framework. Application MUST NOT import infrastructure. Infrastructure MAY import application + domain. Bootstrap MAY import everything.
ArchUnit enforces this at build time per testing.md §3.3.
Companion Commands & Agents
| Need | Command / Agent |
|---|---|
| New port + adapter scaffold | /arch-scaffold (arch-port-scaffolder) |
| Add metrics decorator | /arch-otel (arch-observability-injector) |
| Add Liquibase migration | /arch-migrate (arch-liquibase-migrator) |
| Validate hexagonal compliance on diff | /arch-review (arch-reviewer-hex) |
| Detect missing ADR for significant change | /arch-adr (arch-adr-detector) |
| Validate OpenAPI ↔ controller ↔ DTO | /arch-api (arch-api-contract-validator) |
| Audit perf antipatterns (N+1, blocking I/O) | /arch-perf (arch-perf-profiler) |
| Audit transactional outbox impl | /arch-outbox (arch-outbox-verifier) |
| Audit saga impl | /arch-saga (arch-saga-verifier) |
| STRIDE threat model | /arch-threat (arch-threat-modeler) |
| Audit deps (CVE, drift, BOM, license) | /arch-deps (arch-deps-auditor) |
| Full board-grade architecture document | /arch-doc |
Getting Started Quickly
To understand the codebase: read hexagonal-architecture.md, then ccg-reference.md §Dependency Direction.
To add a feature: follow ccg-domain-and-ports.md → ccg-adapters-and-wiring.md → tests per ccg-bugfix-and-testing.md.
To fix a bug: ccg-bugfix-and-testing.md — RED test first, then minimal fix, then full test pass.
Remember: when in doubt, read the layer rules and follow existing patterns. Consistency over cleverness.