esmeralda / infrastructure
AGENTS.md25 starsChanged 8 days agoApache-2.0View on GitHub
Local rules for Terraform modules and Terragrunt units. The root AGENTS.md still applies. Reference: modules/5-workloads/gateways/envoy/ and docs/src/2-workloads-and-catalog/01-ingress-gateways.md. gateways/direct is the built-in default backend (backend_service_id = null, per-route backends).
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- apps/agents/AGENTS.mdAGENTS.md
- apps/services/AGENTS.mdAGENTS.md
- packages/esmeralda/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- docs/src/llms.txtllms.txt
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 0 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 37
When a unit must validate/plan before its dependency has been applied, add mock_outputs with mock_outputs_allowed_terraform_commands = …
- Very specific: line 42
Write or reuse the module under modules/.
- Very specific: line 43
Add the unit under live/dev/...
- Very specific: line 46
If it needs a Make target, add it to the root Makefile with a ## help comment.
- Very specific: line 62
Never edit state by hand or run terraform state rm/mv / import without explicit intent.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
infrastructure/AGENTS.md
Local rules for Terraform modules and Terragrunt units. The root AGENTS.md still applies.
Layout
modules/<n>-<layer>/: Terraform modules (main.tf,variables.tf,outputs.tf, optionalversions.tf). Layer 5 is split into5-workloads/{services,agents,gateways,entrypoint,apihub}/<name>/.live/root.hcl: included by every unit. Generatesprovider.tf(google + google-beta, region fromenv.yaml) andbackend.tf.live/<env>/env.yaml: per-env settings (prefix, region, state backend, BYO toggles, images,gateways, monitoring).live/shared/env.yamlserves L0.live/<env>/layer-*/.../terragrunt.hcl: one unit per module instance.devandprdhave the same unit tree; keep them in sync.
Unit conventions
Every unit:
include "root" {
path = find_in_parent_folders("root.hcl")
}
locals {
env_vars = read_terragrunt_config(find_in_parent_folders("env.yaml"))
}
terraform {
source = "../../../../../modules//5-workloads/services/<name>" # note the `//`
}- Inputs come from
local.env_vars.locals.*anddependency.<x>.outputs.*. Never hardcode project IDs, SA emails or URLs. - Paths to repo files use
get_repo_root()(e.g.tools_spec_path,agent_config_path). - Optional units use an
exclude { if = ..., actions = ["all"] }block driven byenv.yaml(seegateways/envoy).
Dependencies and mocks
- Depend only on lower layers, or on earlier L5 units (services → agents → gateways → entrypoint → iap-egress).
- When a unit must
validate/planbefore its dependency has been applied, addmock_outputswithmock_outputs_allowed_terraform_commands = ["validate", "plan"](andmock_outputs_merge_strategy_with_state = "shallow"where outputs may be partially present). Mocks must never reachapply. - A dependency that is conditionally used has
enabled = <condition>and is read withtry(dependency.x.outputs.y, null)(seelayer-5-workloads/entrypoint/terragrunt.hcl).
Adding a unit
- Write or reuse the module under
modules/; declare typed variables with descriptions and expose the outputs other units need. - Add the unit under
live/dev/...and the same unit underlive/prd/.... - Workloads with an image resolve the tag to a digest at plan time (
services/*/image.tf→local.image_by_digest; thegoogle_artifact_registry_docker_imagedata source inagents/*). Neverimage = var.…. - Anything agents must reach needs an Agent Registry entry and must be listed in
layer-5-workloads/services/iap-egress(registry_service_ids). - If it needs a Make target, add it to the root
Makefilewith a## helpcomment. make test-terraform, thenterragrunt planin the unit directory.
Adding a gateway adapter
- Module
modules/5-workloads/gateways/<name>/with outputsbackend_service_id(regionalINTERNAL_MANAGEDbackend service in the gateway project) androutes(host,probeper host). No load balancer, certificate or DNS record. - Live unit
live/<env>/layer-5-workloads/gateways/<name>/with anexcludeblock when<name>is not ingateways.enabled. - In
live/<env>/layer-5-workloads/entrypoint/terragrunt.hcl: onedependency "<name>"block (enabled = contains(local.env_vars.locals.gateways.enabled, "<name>"), mockedbackend_service_id) plus its entry ininputs.backends. - Enable it in
env.yamlgateways(move hosts one at a time withhost_rules), apply the gateway, thenmake deploy-entrypoint ENV=<env>, thenmake test-gateway ENV=<env>and a realmake query ... TARGET=remote.
Reference: modules/5-workloads/gateways/envoy/ and docs/src/2-workloads-and-catalog/01-ingress-gateways.md. gateways/direct is the built-in default backend (backend_service_id = null, per-route backends).
State
- Backend is chosen in
root.hcl: GCS whenstate_projectandstate_bucketare set inenv.yaml, otherwise local files underlive/.local_states/<unit path>/terraform.tfstate. - State, plans,
.terraform/,.terragrunt-cache/and.terraform.lock.hclare gitignored; never commit them.make cleandeletes local*.tfstate*files. - Never edit state by hand or run
terraform state rm/mv/importwithout explicit intent.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

