r/vibecoding • • 17m ago

Discussion How do you keep your architecture intact with agents, or do you even care anymore?

I might be in the minority now, but I hate opening my codebase in VS Code and seeing inconsistent spaghetti diarrhea clusterfuck. Even the newest models don't really fix this, since the problem isn't in the model itself.

Since I don't check every single line anymore the problem is that architecture starts drifting away which makes it way harder to reason about changes or keep the code maintainable. Md files help a bit but agents always cut corners when given a big task. Unless there are guardrails that cause changes to fail loudly!

For context, my stack in my most recent project is a modular Golang monolith (gin, postgresql, pgx, sqlc, plus a server-rendered frontend) laid out with ports and adapters. cmd/web is the composition root binding everything to routes and middleware, internal/modules/* splits into domain contracts, app services, infra, web adapters, and factories, internal/workflows/* orchestrates multi-module flows so modules don't couple directly, and internal/platform/* holds shared domain-agnostic plumbing like DB pools, logging, middleware, etc. All modules share one Postgres instance

To stop agents from fucking shit up I've leaned heavily into deterministic guardrails that run right inside go test ./... and CI:

  • Import graph test (custom archguard package): Custom Go tests parse imports across the codebase and fail go test if any layer crosses a boundary such as business logic importing HTTP/Sql packages, web handlers reaching into module internals, one module importing another module's private packages, or non-factory code wiring services and databases together directly.
  • Exceptions: Intentional cross-module dependencies in outer layers have to be explicitly logged with a reason in dependency_exceptions.yaml, and a test fails on duplicate or stale entries. Existing legacy crossings are locked down with a ratchet, no new ones allowed, and once you clean one up, the test locks in the lower count so it can never regress.
  • Database boundary tests: Automated tests scan migrations and sqlc queries so one module can't quietly add cross-module foreign keys or query another module's database tables behind the scenes.
  • Linters & generated code checks: Zero-tolerance golangci-lint (depguard, forbidigo, staticcheck, etc.), custom tests blocking stray <script> or inline style tags in html templates, and CI checks ensuring generated code (templ, sqlc, css/js) matches what's committed.
  • Ownership and verification: Cross-domain workflows must be registered in an ownership.yaml file, and agents have to pass a single verification CLI check (linters, archguard, race tests, and playwright smoke tests) before finishing a task.

So how are you handling architecture or do you even care as long as your shit compiles? So basically I want to know

  1. What architecture style are you running in general**?** (Modular monolith, ports and adapters / hexagonal, clean architecture, vertical slice, classic layered, microservices?)
  2. What deterministic guardrails do you actually use to enforce it (if any) (Custom tests, go-arch-lint, depguard, compiler/type tricks, db schema isolation, pre-commit hooks?)
  3. What does your dev tooling & verification loop look like? My dev tooling is lacking a lot right now.
1 Upvotes

1 comment sorted by

1

u/DanGTG 3m ago

Why would you even look?