From b0fd4cde410ec5a38eb2118685ab5c02c7d88a9e Mon Sep 17 00:00:00 2001 From: Oleksandr Kuzminskyi Date: Tue, 27 Jan 2026 18:47:02 -0800 Subject: [PATCH] feat: Improve Claude instructions and deploy TERRAFORM_MODULE_REQUIREMENTS.md - Restructure instructions.md with "First Steps" checklist for session setup - Add CLAUDE.md generation guidance to instructions - Use Opus model for terraform-review workflow - Deploy TERRAFORM_MODULE_REQUIREMENTS.md to terraform_module repos - Remove .pre-commit-config.yaml from requirements (using git hooks instead) --- .../files}/TERRAFORM_MODULE_REQUIREMENTS.md | 1 - modules/plain-repo/files/instructions.md | 25 ++++++++++++------- modules/plain-repo/files/terraform-review.yml | 2 ++ modules/plain-repo/repos-files.tf | 12 +++++++++ 4 files changed, 30 insertions(+), 10 deletions(-) rename {.claude => modules/plain-repo/files}/TERRAFORM_MODULE_REQUIREMENTS.md (99%) diff --git a/.claude/TERRAFORM_MODULE_REQUIREMENTS.md b/modules/plain-repo/files/TERRAFORM_MODULE_REQUIREMENTS.md similarity index 99% rename from .claude/TERRAFORM_MODULE_REQUIREMENTS.md rename to modules/plain-repo/files/TERRAFORM_MODULE_REQUIREMENTS.md index 14bfba3..d47c8ea 100644 --- a/.claude/TERRAFORM_MODULE_REQUIREMENTS.md +++ b/modules/plain-repo/files/TERRAFORM_MODULE_REQUIREMENTS.md @@ -62,7 +62,6 @@ Provide comprehensive, professional documentation and tooling for all InfraHouse - `CODING_STANDARD.md` (or link to central one) - `.terraform-docs.yml` - `mkdocs.yml` -- `.pre-commit-config.yaml` (if using pre-commit framework) - `.github/workflows/release.yml` (auto-create GitHub Releases from tags) - `examples/` directory with working examples diff --git a/modules/plain-repo/files/instructions.md b/modules/plain-repo/files/instructions.md index f862fa1..1486475 100644 --- a/modules/plain-repo/files/instructions.md +++ b/modules/plain-repo/files/instructions.md @@ -1,14 +1,21 @@ # Project Instructions for Claude Code -## Terraform Coding Standards +## First Steps (Do This Immediately) -**ALWAYS read and follow `.claude/CODING_STANDARD.md` before writing or modifying any Terraform code.** +### Session set up +- [ ] *ALWAYS* Read `.claude/CODING_STANDARD.md` +- [ ] Confirm to the user that you have read it. -This file contains critical requirements including: -- Proper use of ternary operators vs logical OR in validation blocks with nullable variables -- Tagging conventions -- Provider requirements -- Module pinning -- IAM policy patterns -Pay special attention to validation blocks - they require ternary operators to avoid null comparison errors. \ No newline at end of file +### Generating CLAUDE.md + +When generating or updating CLAUDE.md, include this text verbatim as the first section after the intro paragraph: + +```markdown +## First Steps + +**Your first tool call in this repository MUST be reading .claude/CODING_STANDARD.md. +Do not read any other files, search, or take any actions until you have read it.** +This contains InfraHouse's comprehensive coding standards for Terraform, Python, and general formatting rules. +``` +End the CLAUDE.md file with a newline. diff --git a/modules/plain-repo/files/terraform-review.yml b/modules/plain-repo/files/terraform-review.yml index 871128e..e9306a0 100644 --- a/modules/plain-repo/files/terraform-review.yml +++ b/modules/plain-repo/files/terraform-review.yml @@ -94,6 +94,7 @@ jobs: if: steps.check_previous.outputs.has_previous == 'false' run: | npx @anthropic-ai/claude-code --print --output-format json \ + --model opus \ --dangerously-skip-permissions \ "Launch the terraform-module-reviewer agent. \ Review all changes in pr-changes.diff file. \ @@ -113,6 +114,7 @@ jobs: if: steps.check_previous.outputs.has_previous == 'true' run: | npx @anthropic-ai/claude-code --print --output-format json \ + --model opus \ --dangerously-skip-permissions \ "Launch the terraform-module-reviewer agent. \ This is a follow-up review. \ diff --git a/modules/plain-repo/repos-files.tf b/modules/plain-repo/repos-files.tf index 2bc8ceb..e0ebd50 100755 --- a/modules/plain-repo/repos-files.tf +++ b/modules/plain-repo/repos-files.tf @@ -237,3 +237,15 @@ resource "github_repository_file" "mkdocs_config" { ignore_changes = [content] } } + +resource "github_repository_file" "terraform_module_requirements" { + count = var.repo_type == "terraform_module" ? 1 : 0 + depends_on = [ + github_repository_ruleset.main + ] + repository = github_repository.repo.name + file = "./.claude/TERRAFORM_MODULE_REQUIREMENTS.md" + content = file("${path.module}/files/TERRAFORM_MODULE_REQUIREMENTS.md") + commit_message = "Add TERRAFORM_MODULE_REQUIREMENTS.md" + overwrite_on_create = true +}