|
| 1 | +# AI Agent Instructions for terraform-rancher2-aws |
| 2 | + |
| 3 | +Hello! As an AI assistant working in this repository, please adhere to the following guidelines to ensure your code suggestions align with our project standards. |
| 4 | + |
| 5 | +## 1. Agent Roles & Personas |
| 6 | +Depending on which AI tool is reading this, your expected behavior differs based on the developer's workflow: |
| 7 | +- **GitHub Copilot**: You act primarily as a **PR Code Reviewer**. Your job is to rigorously review code changes against `terraform.md` paradigms and catch structural/formatting issues. Do NOT suggest unnecessary changes or engage in pedantic "bikeshedding"; focus only on strictly enforced rules. |
| 8 | +- **Gemini Code Assist**: You act as a **Conversational Coding Partner**. Your job is to help the developer think through problems, explain complex Terraform architectures, and guide the implementation interactively. |
| 9 | +- **Claude**: You act as an **Autonomous Agent**. Your job is to quickly and efficiently execute tasks, fix PR review feedback generated by Copilot, and handle necessary coding chores with minimal conversational overhead. |
| 10 | + |
| 11 | +## 2. Core Documentation |
| 12 | +Before making architectural or structural changes, you must review: |
| 13 | +- `.claude/rules/terraform.md` - This is our absolute source of truth for Terraform paradigms, attribute ordering, and module structuring. |
| 14 | +- `README.md` - For general deployment and testing requirements. |
| 15 | + |
| 16 | +## 3. AI Workspace Structure (.claude) |
| 17 | +We have adopted the Claude CLI `.claude` directory structure as the universal standard for organizing AI context, regardless of which agent you are. Whenever you need to read or create AI-specific instructions, adhere to this layout: |
| 18 | +- **`CLAUDE.md` / `AGENTS.md`**: Project-level core instructions (this file). |
| 19 | +- **`.claude/rules/*.md`**: Topic-scoped instructions (e.g., Terraform guidelines, Go testing rules). |
| 20 | +- **`.claude/settings.json`**: Permissions, hooks, environment variables. |
| 21 | +- **`.claude/skills/<name>/SKILL.md`**: Reusable prompts and context loading skills. |
| 22 | +- **`.claude/commands/*.md`**: Single-file prompts. |
| 23 | +- **`.claude/agents/*.md`**: Subagent definitions. |
| 24 | +- **`.claude/output-styles/*.md`**: Custom response formatting. |
| 25 | + |
| 26 | +## 4. Key Coding Paradigms (Strictly Enforced) |
| 27 | +- **Attribute Order:** Resources must follow this exact order: `count`, `depends_on`, `for_each`, `source`, `version`, `triggers`, then everything else. |
| 28 | +- **Variables in Locals:** All variables must be mapped to a `locals` block immediately. Resources must *only* reference `locals`, never `var.*` directly. |
| 29 | +- **Count as a Feature Flag:** Do not use `count` as an iterator to provision multiple resources. Use it strictly as a boolean feature flag (`0` or `1`). |
| 30 | +- **Module Tiers:** Understand the difference between Core, Primary, Secondary, and Implementation modules. **Never nest local modules!** |
| 31 | +- **Explicit Dependencies:** Always explicitly state `depends_on` blocks, even if Terraform can infer the dependency graph organically. |
| 32 | + |
| 33 | +## 5. Sub-Project Contexts |
| 34 | +If you are asked to work in specific directories or examples, check the `.claude/skills/` directory for context loaders, or the local implementation documentation: |
| 35 | +- Downstream deployments: Read `.claude/skills/load-downstream-context/SKILL.md` |
| 36 | +- Production deployments: Read `examples/prod/README.md` (to be migrated to `.claude/skills/`) |
| 37 | + |
| 38 | +## 6. Testing |
| 39 | +When writing tests or evaluating infrastructure, remember that state files are kept local for example implementations. |
| 40 | +Always advise developers to use the `cleanup.sh` and `run_tests.sh` scripts to handle leftover AWS resources and ensure an idempotent testing environment. |
0 commit comments