com um clique
ipa-init
Initialize IPA project configuration
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Menu
Initialize IPA project configuration
Instalar com Codex ou Claude Copie este prompt, cole no Codex, Claude ou outro assistente e deixe que ele revise a página da skill e instale para você.
Baseado na classificação ocupacional SOC
Deploy a backend tier stack: Lambda + API Gateway v2 + DynamoDB (feature-flagged).
Compose a deployment from stack skills and generate executable artifacts (Makefiles, security disposition). Use when the user says 'compose', 'generate deployment', or invokes /ipa-compose.
Deploy a CodePipeline CI/CD pipeline with CodeBuild for automated build/test/deploy.
Deploy a Terraform state backend (S3 + DynamoDB) via CloudFormation.
Deploy a CodeCommit repository for source code management.
Deploy a Cognito User Pool stack with OAuth 2.0 Hosted UI and OIDC endpoints.
| name | ipa-init |
| description | Initialize IPA project configuration |
| model | opus |
This skill interactively configures a project's .env file with the IPA-managed variables required by all other IPA skills (/ipa-compose, /ipa-prepare, /ipa-deploy). It auto-detects the AWS account ID, provides sensible defaults, and validates all input. When the builder selects APP_IAC=terraform, the skill also bootstraps the Terraform state backend (S3 + DynamoDB via CloudFormation) so the project is deploy-ready in a single step.
Lifecycle: /ipa-init → /ipa-compose → /ipa-prepare → /ipa-deploy
The .env file contains up to seven IPA-managed variables. AWS_PROFILE is optional — if the builder skips it, the line is omitted from .env. The agent MUST set all other six variables during initialization.
| Variable | Prompted | Default | Description |
|---|---|---|---|
AWS_PROFILE | Yes | (none) | AWS CLI profile name (optional — omit to use default credential chain) |
AWS_REGION | Yes | us-east-1 | AWS region for deployments |
AWS_ACCOUNT_ID | Auto-detect, confirm | (none) | 12-digit AWS account ID |
APP_NAMESPACE | Yes | app | Project name prefix for stack naming (max 12 chars) |
APP_ENV | Yes | dev | Environment label (e.g., dev, stage, prod) |
APP_CODE_AGENT | No (auto-set) | claude-code | AI agent platform — set automatically, do not prompt |
APP_IAC | Yes | cloudformation | Infrastructure-as-code tool (cloudformation or terraform) |
TF_STATE_BUCKET | No (derived) | (none) | S3 bucket for Terraform state — written by Step 4.5 after CFN deploy. Only when APP_IAC=terraform. |
TF_STATE_LOCK_TABLE | No (derived) | (none) | DynamoDB table for state locking — written by Step 4.5 after CFN deploy. Only when APP_IAC=terraform. |
AWS_PROFILE (optional — can be skipped), AWS_REGION, APP_NAMESPACE, APP_ENV, APP_IAC — ask the builder for a value, offer default if one exists.AWS_ACCOUNT_ID — detect via AWS CLI and auto-accept, fall back to manual prompt on failure.APP_CODE_AGENT — set silently without prompting. Fixed for this iteration.The .env file uses standard KEY=VALUE format:
=#Example (with profile):
# IPA Project Configuration
# Generated by /ipa-init — local only, do not commit
AWS_PROFILE=my-profile
AWS_REGION=us-east-1
AWS_ACCOUNT_ID=123456789012
APP_NAMESPACE=myproject
APP_ENV=dev
APP_CODE_AGENT=claude-code
APP_IAC=cloudformation
Example (no profile — uses default credential chain):
# IPA Project Configuration
# Generated by /ipa-init — local only, do not commit
AWS_REGION=us-east-1
AWS_ACCOUNT_ID=123456789012
APP_NAMESPACE=myproject
APP_ENV=dev
APP_CODE_AGENT=claude-code
APP_IAC=cloudformation
You MUST validate every value before writing .env. If a value fails validation, reject it with the specific error message below and re-prompt the builder.
| Variable | Pattern | Error Message |
|---|---|---|
AWS_PROFILE | Non-empty string, or none to skip | "AWS_PROFILE must be a profile name or 'none' to skip" |
AWS_REGION | /^[a-z]{2}-[a-z]+-\d+$/ | "Invalid region format — expected format like us-east-1" |
AWS_ACCOUNT_ID | /^\d{12}$/ | "Invalid account ID — must be exactly 12 digits" |
APP_NAMESPACE | /^[a-z][a-z0-9-]{0,11}$/ | "Invalid namespace — must be 1-12 chars, lowercase letters/digits/hyphens, must start with a letter" |
APP_ENV | /^[a-z][a-z0-9-]{0,11}$/ | "Invalid environment — must be 1-12 chars, lowercase letters/digits/hyphens, must start with a letter" |
APP_IAC | cloudformation or terraform | "Invalid IaC tool — must be 'cloudformation' or 'terraform'" |
.env if any value is invalid.APP_CODE_AGENT is auto-set to a fixed value and does not require validation.Check if .env exists at the project root:
.env is missing or empty (zero bytes or only whitespace/comments): enter the First-Time Initialization flow below..env exists and contains at least one KEY=VALUE pair: enter the Re-Initialization flow (see next section).Use a SINGLE AskUserQuestion call with all 5 questions. Do NOT ask them one at a time.
Before the prompt, display:
Let's configure your project. Answer the five questions below. Sensible defaults are pre-selected — accept them all for the fastest setup.
Questions (all in one AskUserQuestion call):
AWS_PROFILE (header: "Profile", multiSelect: false)
AWS_PROFILE from .env entirely (do not write the line).AWS_REGION (header: "Region", multiSelect: false)
APP_NAMESPACE (header: "Namespace", multiSelect: false)
{namespace}-{env}-. Must be unique per account+environment. (1-12 chars, lowercase letters/digits/hyphens, starts with letter)"APP_ENV (header: "Env", multiSelect: false)
APP_IAC (header: "IaC Tool", multiSelect: false)
cloudformation or terraform)After receiving all 5 answers from the batched prompt:
Validate all values per the Validation Rules section. Check every value, then:
Validation failed:
APP_NAMESPACE: "my--project" — Invalid: cannot contain consecutive hyphens
Re-enter APP_NAMESPACE (1-12 chars, lowercase letters/digits/hyphens, starts with letter):
Auto-detect AWS_ACCOUNT_ID using the profile from Question 1:
aws sts get-caller-identity --query Account --output textaws sts get-caller-identity --profile <profile> --query Account --output text<detected_value>"/^\d{12}$/. This is the ONLY scenario that adds an extra interaction.Auto-set (do not prompt):
APP_CODE_AGENT=claude-codeDisplay a summary table of all values:
┌─────────────────┬──────────────────┬───────────────┐
│ Variable │ Value │ Source │
├─────────────────┼──────────────────┼───────────────┤
│ AWS_PROFILE │ my-dev-admin │ prompted │
│ AWS_REGION │ us-east-1 │ default │
│ AWS_ACCOUNT_ID │ 123456789012 │ auto-detected │
│ APP_NAMESPACE │ myproject │ prompted │
│ APP_ENV │ dev │ default │
│ APP_CODE_AGENT │ claude-code │ auto-set │
│ APP_IAC │ cloudformation │ default │
└─────────────────┴──────────────────┴───────────────┘
The Source column MUST indicate how each value was determined:
prompted — builder typed the valuedefault — builder accepted the defaultskipped — builder chose to omit this variable (AWS_PROFILE only)auto-detected — detected from AWS CLI (auto-accepted, no confirmation)auto-set — set automatically, not promptedIf AWS_PROFILE was skipped, show it as:
│ AWS_PROFILE │ (not set) │ skipped │
and do NOT write the AWS_PROFILE= line to .env.
Immediately write .env in KEY=VALUE format with the header comment block. Do NOT ask "Does this look correct?" — the builder confirmed their choices in the batched prompt.
After writing, display: "Configuration written to .env. Re-run /ipa-init to change any values."
If APP_IAC=terraform, proceed to Step 4.5: Bootstrap Terraform State Backend. Otherwise, proceed to Step 5: Next Step Guidance.
This step runs only when APP_IAC=terraform. Skip entirely for cloudformation.
Terraform requires a state backend (S3 bucket + DynamoDB lock table) to exist before any module can run. Bootstrapping it during /ipa-init makes the project deploy-ready in one step — /ipa-compose then generates Makefiles that work on first run, with no separate prepare step required for state.
Before deploying anything:
Credentials available? If AWS_ACCOUNT_ID was set via manual fallback (auto-detection failed in Step 3), credentials are not usable for CFN deploy. Display:
Cannot bootstrap Terraform state backend. AWS credentials are not configured (
aws sts get-caller-identityfailed earlier). After configuring credentials, runmake -f scripts/prepare.mk prepare-tfstateonce/ipa-composehas generatedprepare.mk(the prepare target is the fallback path for state-backend bootstrapping).
Skip the deploy and proceed to Step 5: Next Step Guidance. The skill does NOT fail.
CloudFormation template present? Verify infra/cfn/tfstate/tfstate.yml exists. If not, display an error and skip the bootstrap (same fallback messaging as above).
Display:
Bootstrapping Terraform state backend — deploying
{APP_NAMESPACE}-{APP_ENV}-tfstate(S3 bucket + DynamoDB lock table). This typically takes 30-60 seconds.
Run:
aws cloudformation deploy \
--stack-name {APP_NAMESPACE}-{APP_ENV}-tfstate \
--template-file infra/cfn/tfstate/tfstate.yml \
--parameter-overrides Namespace={APP_NAMESPACE} Environment={APP_ENV} \
--no-fail-on-empty-changeset \
$(if AWS_PROFILE,--profile AWS_PROFILE,) \
--region {AWS_REGION}
The --no-fail-on-empty-changeset flag makes re-runs safe — if the stack already exists with the same parameters, the command is a no-op.
Query the stack for StateBucketName and LockTableName:
aws cloudformation describe-stacks \
--stack-name {APP_NAMESPACE}-{APP_ENV}-tfstate \
--query 'Stacks[0].Outputs[?OutputKey==`StateBucketName`].OutputValue' \
--output text \
$(if AWS_PROFILE,--profile AWS_PROFILE,) \
--region {AWS_REGION}
Repeat for LockTableName.
Append (or replace, if already present) two lines under a # Terraform State Backend header:
# Terraform State Backend (written by /ipa-init after tfstate deploy)
TF_STATE_BUCKET=<StateBucketName>
TF_STATE_LOCK_TABLE=<LockTableName>
Use the same grep -v strip-then-append idiom that env.mk uses, so re-runs converge to the same content.
If the deploy or describe-stacks call fails:
After 4.5 completes (success or fallback), proceed to Step 5: Next Step Guidance.
This flow runs when .env already exists and contains at least one KEY=VALUE pair.
Read the .env file line by line.
Separate lines into two groups:
AWS_PROFILE, AWS_REGION, AWS_ACCOUNT_ID, APP_NAMESPACE, APP_ENV, APP_CODE_AGENT, APP_IAC, TF_STATE_BUCKET, TF_STATE_LOCK_TABLETF_STATE_BUCKET and TF_STATE_LOCK_TABLE are written by Step 4.5 when APP_IAC=terraform. They are NOT prompted in any flow — preserve them in re-init exactly as found.
If the file is malformed (e.g., lines with no = delimiter that aren't comments or blank), warn the builder: "Some lines in .env appear malformed. Would you like to repair them or keep them as-is?" Offer to fix or preserve.
Show the builder their current IPA configuration:
Current IPA Configuration:
┌─────────────────┬──────────────────┐
│ Variable │ Current Value │
├─────────────────┼──────────────────┤
│ AWS_PROFILE │ my-dev-admin │
│ AWS_REGION │ us-east-1 │
│ AWS_ACCOUNT_ID │ 123456789012 │
│ APP_NAMESPACE │ myproject │
│ APP_ENV │ dev │
│ APP_CODE_AGENT │ claude-code │
│ APP_IAC │ cloudformation │
└─────────────────┴──────────────────┘
If extra (non-IPA) variables exist, note: "Your .env also contains N additional variable(s) not managed by IPA. These will be preserved."
Ask: "Which values would you like to change? (enter variable names separated by commas, or 'none' to keep all):"
APP_CODE_AGENT is auto-set and cannot be changed by the builder.Special case — AWS_PROFILE changed: If the builder changes AWS_PROFILE, re-run AWS_ACCOUNT_ID auto-detection using the new profile. Present the new detected value for confirmation. If detection fails, ask if they want to update AWS_ACCOUNT_ID manually.
If the builder changed APP_NAMESPACE or APP_ENV, display this warning BEFORE confirmation:
Warning: You changed
APP_NAMESPACEand/orAPP_ENV. These values are baked into Makefiles by/ipa-compose. You MUST re-run/ipa-composeafter this update to regenerate Makefiles with the new values.
If the builder changed APP_IAC (e.g., cloudformation → terraform or vice versa), this is a major change that breaks state continuity. Stacks deployed by the previous engine are invisible to the new one.
Before confirmation, display:
DANGER: Switching IaC engine from
{old}to{new}.Resources deployed by
{old}are NOT visible to{new}and will not be managed, updated, or torn down by the new engine. Switching engines on a project with deployed infrastructure typically results in:
- Orphaned resources you must clean up manually
- Duplicate resource creation if you redeploy with the new engine (name collisions)
- Lost ability to use
/ipa-destroyagainst the old stacksRecommended path: Run
/ipa-destroy(and any manual prepare-stack teardowns) BEFORE switchingAPP_IAC. Then run/ipa-initto switch, followed by/ipa-composeand/ipa-prepare.If you have NOT yet deployed any stacks, switching is safe.
Use AskUserQuestion to require explicit confirmation:
APP_IAC={old}" (Recommended)If the builder cancels, leave APP_IAC unchanged and continue with any other selected updates. If the builder proceeds and the new value is terraform, the post-write flow MUST run Step 4.5: Bootstrap Terraform State Backend (same as first-time init) so TF_STATE_BUCKET and TF_STATE_LOCK_TABLE are populated.
Display a summary of changes only (unchanged values marked as "unchanged"):
┌─────────────────┬──────────────────┬──────────────────┬───────────┐
│ Variable │ Old Value │ New Value │ Status │
├─────────────────┼──────────────────┼──────────────────┼───────────┤
│ AWS_PROFILE │ my-dev-admin │ my-prod-admin │ changed │
│ AWS_REGION │ us-east-1 │ us-east-1 │ unchanged │
│ AWS_ACCOUNT_ID │ 123456789012 │ 987654321098 │ changed │
│ APP_NAMESPACE │ myproject │ myproject │ unchanged │
│ APP_ENV │ dev │ dev │ unchanged │
│ APP_CODE_AGENT │ claude-code │ claude-code │ auto-set │
│ APP_IAC │ cloudformation │ cloudformation │ unchanged │
└─────────────────┴──────────────────┴──────────────────┴───────────┘
Ask: "Does this look correct? (yes to write, no to start over):"
.env preserving all extra (non-IPA) variables in their original positions. IPA variables are written as a group with the standard header comment. Then:
APP_IAC was changed to terraform: run Step 4.5 (Bootstrap Terraform State Backend).APP_IAC was changed to cloudformation: leave existing TF_STATE_BUCKET / TF_STATE_LOCK_TABLE lines in .env (they are harmless when unused; the builder may switch back later)..env untouched. Proceed to Step 5: Next Step Guidance.When rewriting .env:
After .env is written, display:
Initialization complete.
Next: Run `/ipa-compose` to compose infrastructure and generate Makefiles.
Security configuration is handled automatically on first compose.
Do NOT invoke any other skill. The builder runs /ipa-compose next.
If .env exists but contains lines that are not valid KEY=VALUE pairs, comments, or blank lines:
= delimiter that aren't comments). These lines may cause issues."After the builder provides AWS_PROFILE (skip this check if the builder chose to omit the profile), check if it exists in ~/.aws/config or ~/.aws/credentials:
aws configure list-profiles (or check the config files directly).APP_NAMESPACE is used in stack names via {namespace}-{env}-{service}. The validation regex (/^[a-z][a-z0-9-]{0,11}$/) already prevents most invalid names, but additionally:
--).If aws sts get-caller-identity fails for any reason:
AWS_ACCOUNT_ID.If .env exists but contains only whitespace, blank lines, or comments (no KEY=VALUE pairs):
.env).