Sitemap
Globant

Our thoughts as a strategic disruptor in business and cognitive transformation. Visit us at www.globant.com

The AI Engineering Constitution — Part 1: Why AI Needs Guardrails

The Case for Structured AI-Assisted Development

4 min readOct 30, 2026

--

Constructing robust system architecture block by block.

What if every generated class followed the same naming conventions, every endpoint respected the same layered boundaries, and every PR passed your review checklist — automatically?

This is the promise of what I call an AI Engineering Constitution. It is a set of machine-readable rules and principles that govern how an AI agent generates code for your project. After building a complete Spring Boot API using Claude Code guided by such a constitution, I’m convinced this is the future of AI-assisted development.

In this five-part series, I’ll share the philosophy, rules, workflow, and hard-won lessons. I’ve generalized the approach so any team can adopt it regardless of framework or language. Here’s how the series is structured:

  • Part 1 (this article) — Why AI assistants produce inconsistent code without explicit guidance, and what an AI Engineering Constitution looks like in practice.
  • Part 2: Architecture Rules — Defining layer boundaries, dependency direction, API design standards, and database conventions — the structural foundation every generation must respect.
  • Part 3: Code Generation Rules — Establishing naming conventions, code templates, pre-generation analysis, and prohibited/required patterns — the style guide the AI follows for every line of code.
  • Part 4: Review Checklist & Workflow — A self-verification system across eight dimensions, the full seven-step development workflow, and the measurable benefits this approach delivers.
  • Part 5: Lessons from Production — Prompting strategy, embedded design principles, and the challenges and lessons learned from months of production use — plus practical tips for teams adopting this approach.

By the end of this series, you’ll be able to replace a 200-word prompt with a 6-word command — and get code that passes your team’s review checklist on the first try.

The Problem: AI Without Guardrails

Out of the box, AI coding assistants are impressive but inconsistent. Ask one to generate a REST endpoint today and tomorrow, and you’ll likely get different results each time. You might see:

  • Different naming conventions
  • Business logic leaking into controllers
  • Entities exposed directly in API responses
  • Inconsistent error handling
  • Missing validation and tests

The AI doesn’t “remember” your architecture. Every prompt starts from zero context unless you give it structure. AI assistants optimize for plausibility, not consistency. They generate code that looks correct but doesn’t necessarily follow your team’s specific conventions.

Get Anurag Pandit’s stories in your inbox

Join Medium for free to get updates from this writer.

This inconsistency compounds over time. One developer getsOrderRepo, another getsOrderRepository, and a third gets OrderDao. The codebase becomes a patchwork of styles, and every code review turns into a formatting debate instead of a logic discussion.

The Solution: An AI Engineering Constitution

An AI Engineering Constitution is a collection of Markdown documents placed inside your repository that define three things:

  • Architecture Rules — layer boundaries, package structure, and dependency direction
  • Code Generation Rules — templates, naming conventions, and prohibited and required patterns
  • Review Checklist — verification criteria applied to every piece of generated code

These documents live in a root CLAUDE.md file and are scoped at both global and directory levels. The root file contains core principles and navigation, while directory-specific rules live alongside the code they govern. When the agent works in a specific layer, it loads only the relevant context — preventing information overload and keeping focus sharp.

The structure follows a scoped approach:

project-root/
├── CLAUDE.md (Root - Navigation & core principles)
├── .ai/
│ ├── architecture-rules.md (High-level only)
│ └── review-checklist.md
└── src/
├── controller/
│ └── CLAUDE.md (Controller-specific rules)
├── service/
│ └── CLAUDE.md (Service layer rules)
└── repository/
└── CLAUDE.md (Database & repository rules)

Note: In a real Spring Boot project, paths would be src/main/java/com/example/app/controller/CLAUDE.md etc. The structure above is simplified for clarity.

To make this concrete, here’s what a directory-level CLAUDE.md actually looks like for the controller layer:

Press enter or click to view image in full size
A real CLAUDE.md file for the controller layer — rules the AI loads only when working on controller code

This is a simplified example — your actual rules will be more detailed. Notice how it defines conventions, HTTP status codes, and canonical file references all in one place. The key is that these rules load only when the AI works on controller code, keeping the context focused.

The root CLAUDE.md contains universal principles (security, naming conventions). Directory-level files like the one above hold domain-specific rules that load only when Claude works in that area, preventing context overload. This is what transforms a general-purpose assistant into a team-aware collaborator.

Why is this important? By scoping rules to directories, you keep each context focused and avoid overwhelming the AI with irrelevant instructions. A lean, well-organized constitution outperforms an exhaustive but bloated one. (We’ll dive deeper into context management in Part 5.)

What’s Next

We’ve identified the problem — inconsistent AI output — and the solution — a structured, scoped set of machine-readable rules. But what exactly goes into those rules?

In Part 2, we’ll build the first pillar: Architecture Rules. These define where code lives, how layers communicate, and why each structural decision exists—giving the AI the same architectural awareness as a senior developer who's been on the team for months.

Continue to Part 2: Architecture Rules →

If you found this useful, follow me for the rest of the series. Have questions about setting up your own AI Engineering Constitution? Drop them in the comments.

Read the complete 5-part article series:

--

--

Anurag Pandit
Anurag Pandit

Written by Anurag Pandit

Java developer skilled in Spring Boot, REST, GraphQL, and microservices, focused on building scalable applications and sharing backend insights.

Globant
Globant

Published in Globant

Our thoughts as a strategic disruptor in business and cognitive transformation. Visit us at www.globant.com