원클릭으로
cleanup
Detect and delete leftover AWS resources from cdkd integration tests. Only targets resources matching known cdkd stack name patterns.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Detect and delete leftover AWS resources from cdkd integration tests. Only targets resources matching known cdkd stack name patterns.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Proactively hunt for cdkd bugs by deploying real CDK apps that exercise common-but-untested AWS resources, configs, and CloudFormation notations against real AWS, then fix what breaks. Use for a periodic "find latent bugs" sweep, not for verifying a specific change.
Work through already-filed GitHub issues (typically the bug-hunt's output) end to end — triage safely, pick a few FILE-DISJOINT issues to fix in parallel, claim each on the issue before starting (collision-safe with other agents), verify against real AWS, then carry each through merge → pull → release → rebuild the linked binary → worktree cleanup. Use when asked to "handle/address filed issues", not to hunt for new bugs (that is /hunt-bugs).
Recommend which integration tests to run, based on the integ ledger (staleness / last result) plus the code areas touched by recent commits. Outputs a prioritized list of `/run-integ <name>` commands. Use before a release, after a batch of merges, or when unsure what integ coverage a change needs.
Scaffold a new integration test for cdkd. Creates a minimal CDK app with the specified AWS resources for deploy/destroy E2E testing.
Run integration tests (deploy + destroy) against real AWS. Use when you need to verify cdkd works end-to-end with actual AWS resources.
Recommend the right reviewer count for a PR based on size + bias factors. Outputs a concrete plan (inline spot-check / 1 reviewer / 3-axis parallel) plus ready-to-paste Agent dispatch prompts when reviewers are warranted.
| name | cleanup |
| description | Detect and delete leftover AWS resources from cdkd integration tests. Only targets resources matching known cdkd stack name patterns. |
| argument-hint | [stack-name-prefix] [--detect-only] |
Detect and optionally delete AWS resources left behind by cdkd integration tests.
AskUserQuestion for confirmation before deleting anythingstack-name-prefix: Filter by specific stack name prefix (e.g., EcrStack, LambdaStack). If not specified, scan all known cdkd test stack prefixes.--detect-only: Only list leftover resources, don't delete (this is the default)Determine stack name prefixes to scan:
bin/app.ts in each tests/integration/*/ directory. Look for the CDK construct ID (second argument to new *Stack(app, '<id>'))Resolve region and account: Scan both us-east-1 and ap-northeast-1. Resolve account ID via aws sts get-caller-identity. IAM is global so only needs one query.
Check S3 state: aws s3 ls s3://cdkd-state-{accountId}-us-east-1/stacks/ --region us-east-1
3.5. Bulk-sweep orphaned deployment-event stores (issue #885 follow-up): since the
deployment-events feature (#820), cdkd destroy / cdkd state destroy removes
state.json but, unless --purge-events was passed, INTENTIONALLY leaves the
cdkd/{stack}/{region}/deployments/ event store behind (post-mortem history). After
a long integ campaign those orphaned event stores accumulate across dozens of
already-destroyed stacks, so aws s3 ls .../cdkd/ is never empty even when there are
no real state / resource leaks. This step bulk-removes them. Safety: only a prefix
that has a deployments/ child AND NO state.json under any region is an orphan —
a prefix that still has a state.json is an ACTIVE (deployed, not destroyed) stack
and MUST be left untouched (its deployments/ is live history).
Resolve the state bucket(s) (cdkd-state-{accountId} current default; also the legacy
cdkd-state-{accountId}-{region} if present), then per bucket:
BUCKET="cdkd-state-{accountId}"
# List each top-level prefix under cdkd/ (one per stack), skip the exports index.
for p in $(aws s3 ls "s3://${BUCKET}/cdkd/" --region us-east-1 | awk '{print $2}' | grep '/$' | grep -v '^_index/'); do
listing=$(aws s3 ls "s3://${BUCKET}/cdkd/${p}" --recursive --region us-east-1 2>/dev/null)
has_state=$(echo "$listing" | grep -c 'state.json')
has_dep=$(echo "$listing" | grep -c 'deployments/')
# An ACTIVE stack still has a state.json somewhere under the prefix.
if [ "$has_state" -eq 0 ] && [ "$has_dep" -gt 0 ]; then
echo "ORPHAN event store (no state.json): cdkd/${p}"
fi
done
Report the orphan list, confirm via AskUserQuestion (unless --detect-only), then
delete each confirmed orphan prefix with
aws s3 rm "s3://${BUCKET}/cdkd/${p}" --recursive --region us-east-1. Re-run the
has_state check immediately before each delete to guard against a concurrent deploy
that re-created the stack. The per-stack product-level equivalent (for a user who
knows the stack name) is cdkd events prune <stack> --all; this skill step is the
bucket-wide bulk sweep for integ-test hygiene.
Scan AWS resources for each stack name prefix. Use both exact case and lowercase variants since some AWS services lowercase names:
aws iam list-roles --query 'Roles[?contains(RoleName, \{Prefix}`)].{Name:RoleName,Arn:Arn}'`aws iam list-policies --scope Local --query 'Policies[?contains(PolicyName, \{Prefix}`)].{Name:PolicyName,Arn:Arn}'`aws lambda list-functions --region us-east-1 --query 'Functions[?contains(FunctionName, \{Prefix}`)].FunctionName'`aws s3api list-buckets --query 'Buckets[?contains(Name, \{prefix}`)].Name'`aws dynamodb list-tables --region us-east-1 --query 'TableNames[?contains(@, \{Prefix}`)]'`aws ecr describe-repositories --region us-east-1 --query 'repositories[?contains(repositoryName, \{prefix}`)].repositoryName'`aws sqs list-queues --region us-east-1 --queue-name-prefix {Prefix} (if supported)aws sns list-topics --region us-east-1 then filter by prefixaws logs describe-log-groups --region us-east-1 --log-group-name-prefix /aws/lambda/{Prefix}aws ec2 describe-security-groups --region us-east-1 --filters "Name=group-name,Values=*{Prefix}*" --query 'SecurityGroups[].{Id:GroupId,Name:GroupName}'aws ec2 describe-vpcs --region us-east-1 --filters "Name=tag:Name,Values=*{Prefix}*" --query 'Vpcs[].{Id:VpcId,Name:Tags[?Key==\Name`].Value|[0]}'`aws kinesis list-streams --region us-east-1 --query 'StreamNames[?contains(@, \{Prefix}`)]'. **Provisioned streams bill continuously**, so surface these first. Delete with aws kinesis delete-stream --stream-name {name} --region us-east-1`.aws firehose list-delivery-streams --region us-east-1 --query 'DeliveryStreamNames[?contains(@, \{Prefix}`)]'. Delete with aws firehose delete-delivery-stream --delivery-stream-name {name} --region us-east-1`.aws pipes list-pipes --region us-east-1 --query 'Pipes[?contains(Name, \{Prefix}`)].Name'. Delete with aws pipes delete-pipe --name {name} --region us-east-1`.aws scheduler list-schedules --region us-east-1 --query 'Schedules[?contains(Name, \{Prefix}`)].Name'. Delete with aws scheduler delete-schedule --name {name} --region us-east-1`.aws synthetics describe-canaries --region us-east-1 --query 'Canaries[?contains(Name, \{prefix}`)].{Name:Name,Id:Id}'(canary names are lowercased). Stop if running, then delete withaws synthetics delete-canary --name {name} --region us-east-1`.aws cognito-idp list-user-pools --max-results 60 --region us-east-1 --query 'UserPools[?contains(Name, \{Prefix}`)].{Name:Name,Id:Id}'. Delete with aws cognito-idp delete-user-pool --user-pool-id {id} --region us-east-1`.aws secretsmanager list-secrets --region us-east-1 --query 'SecretList[?contains(Name, \{Prefix}`)].{Name:Name,Arn:ARN}'. Delete with aws secretsmanager delete-secret --secret-id {arn} --force-delete-without-recovery --region us-east-1`.aws stepfunctions list-state-machines --region us-east-1 --query 'stateMachines[?contains(name, \{Prefix}`)].{Name:name,Arn:stateMachineArn}'. Delete with aws stepfunctions delete-state-machine --state-machine-arn {arn} --region us-east-1`.aws backup list-backup-vaults --region us-east-1 --query 'BackupVaultList[?contains(BackupVaultName, \{Prefix}`)].BackupVaultName'. A vault with recovery points cannot be deleted until they are removed (list-recovery-points-by-backup-vault→delete-recovery-point), then aws backup delete-backup-vault --backup-vault-name {name} --region us-east-1`.for id in $(aws kms list-keys --region us-east-1 --query 'Keys[].KeyId' --output text); do
meta=$(aws kms describe-key --key-id "$id" --region us-east-1 \
--query 'KeyMetadata.{Mgr:KeyManager,State:KeyState,Desc:Description}' --output json)
# Keep only CUSTOMER-managed, Enabled keys whose Description matches a cdkd pattern
echo "$meta" | grep -q '"Mgr": "CUSTOMER"' || continue
echo "$meta" | grep -q '"State": "Enabled"' || continue
echo "$meta" | grep -qi 'cdkd\|bughunt' || continue
echo "KMS candidate: $id -> $meta"
done
Safety (KMS-specific, MUST hold): only KeyManager==CUSTOMER AND KeyState==Enabled keys (never touch AWS-managed keys, and skip anything already PendingDeletion); match cdkd origin via the key Description (integ keys carry descriptions like ... cdkd #609 integ / bughunt sweep11 key A) or tags (aws kms list-resource-tags). Skip any key that is the active API Gateway account CloudWatch role key, or that has active grants (aws kms list-grants --key-id {id}) or aliases (aws kms list-aliases --key-id {id}). KMS keys cannot be deleted immediately — schedule deletion with aws kms schedule-key-deletion --key-id {id} --pending-window-in-days 7 --region us-east-1 (7 is the minimum window) and surface the returned DeletionDate in the report.apigateway CloudWatch-role-ARN setting, not the stack, so nothing deletes them on teardown. They match the general IAM-role scan above (e.g. CdkdApigwUsagePlanKeyExample-..., ApiCognitoStack-...), but before deleting one confirm it is not the ARN currently set on the account via aws apigateway get-account; if it is, unset it there first.Report findings: Show a table of detected resources grouped by type
If deletion requested (not --detect-only):
AskUserQuestion to show the full list and confirm deletionaws apigateway get-account that the role is not the active account-level ARN before deleting.--force flagschedule-key-deletion --pending-window-in-days 7 returns a DeletionDate; report it so the user knows the key bills until then. Never delete AWS-managed keys or keys with grants/aliases.DeletionDate)AskUserQuestion/aws/lambda/ are created automatically by Lambda and are safe to clean up if the function name matchesDeletionDate. Only ever touch CUSTOMER-managed + Enabled keys matched to a cdkd description/tag, and never one with active grants, aliases, or the apigateway account CloudWatch role binding.