What the agent does
The agent reads the issue, then the app. In a CDK app shaped like aws-samples/aws-cdk-examples' typescript/api-cors-lambda-crud-dynamodb, index.ts defines ApiLambdaCrudDynamoDBStack with one DynamoDB Table named items under RemovalPolicy.DESTROY, five NodejsFunction constructs on Runtime.NODEJS_24_X bundled with esbuild and the SDK left external, a RestApi called Items Service with items and {id} resources, CORS through a MockIntegration, and at the bottom new App(), one stack named ApiLambdaCrudDynamoDBExample and app.synth(). package.json pins aws-cdk-lib 2.262.1 and the aws-cdk CLI 2.1133.0 with typescript 7, jest 30 and @swc/jest; build is tsc under a tsconfig with noEmit: true, so it is a type check, and cdk.json runs the app with npx tsc && npx tsx index.ts. jest.config.js matches **/*.test.ts and loads aws-cdk-lib/testhelpers/jest-autoclean, but there is no test file. No Tags import appears anywhere in this example.
Two context flags in cdk.json change what tagging means here. @aws-cdk/core:explicitStackTags is true, which means Tags.of(app).add() no longer puts tags on the CloudFormation stack itself; stack-level tags, the ones CloudFormation propagates to resources that support them, must be passed as the tags prop on the Stack. @aws-cdk/core:aspectPrioritiesMutating is true, so tag aspects run at the mutating priority before readonly validations. The agent reads both and does two things rather than one: a tags map on the stack props for stack-level propagation, and Tags.of(app).add() for each key so every taggable resource in the template carries it directly, which is what a cost report or an SCP checks.
The tags and their values come from the issue, with a shape that survives reuse. A tags.ts module exports the required keys, such as Project, Environment, Owner and CostCenter, and reads their values from CDK context so cdk deploy -c environment=prod or an entry in cdk.json sets them without a code change; a missing required value throws at synth with the key named, which the agent prefers to a silent empty tag. The same tags are applied in index.ts right after new App() so a second stack added later inherits them, and the stack gets them in tags. Other examples in the same repository, typescript/rds/mysql and typescript/secrets-manager-rotation, already use Tags.of(...).add('Name', ...) on single resources, so the convention is familiar.
The proof is a jest test that the example's config was waiting for. test/tags.test.ts synthesizes the stack with Template.fromStack and asserts with hasResourceProperties that AWS::DynamoDB::Table, each AWS::Lambda::Function and AWS::ApiGateway::RestApi carry every required key, and reads the stack's tags from the cloud assembly to assert the stack-level set. The agent runs npm install, because the example ships no root lockfile and scripts/build-typescript.sh falls back to a plain install when it finds none, which also installs the lambdas' dependencies through postinstall; then npm run build, npm test, and cdk synth with the repository's fake context in us-east-1 the way synth.sh does on every pull request, and greps the template for each key to show nothing taggable was missed.
Start it with one API call
POST https://api.phoenix.so/o/{org}/sessions with this body:
{
"agent": "claude",
"input": "A Linear issue labelled agent asks for required tags on every resource in this AWS CDK app. Read package.json, cdk.json, tsconfig.json, jest.config.js, index.ts, the lambdas directory and the repository's build scripts first, and note every construct in the stack, the context flags that affect tagging, and whether any Tags call already exists. Add a tags module that defines the required keys from the issue, reads their values from CDK context, and throws at synth with the key named when one is missing. Apply the tags with Tags.of on the app so every taggable resource carries them, and pass them as the stack's tags prop as well because explicitStackTags is on. Write a jest test under test/ that synthesizes the stack with Template.fromStack and asserts the keys on the table, each function and the REST API, plus the stack-level tags from the cloud assembly. Run the install the repository's build script would use given its lockfile or lack of one, then npm run build, npm test and cdk synth with the repository's fake context, and grep the template for each key. Open a pull request that links the issue, lists the keys and where their values come from, and quotes the test and synth output.",
"resources": [
{
"url": "https://github.com/your-org/your-app"
}
]
}- Get an API key. In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
- Send the request. POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
- Read what came back. Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.
What comes back
What comes back is a pull request on its own branch that adds tags.ts and test/tags.test.ts, changes index.ts to apply the tags after new App() and to pass them to the stack, and adds the context defaults to cdk.json so cdk synth works without flags. package.json gains a test script if jest had none, and nothing else changes in the lambdas.
The description links the Linear issue, lists each required key with where its value comes from, quotes npm test from the sandbox with the assertion test passing, and quotes cdk synth with the fake context, followed by the count of resources in the template that carry each key. It explains in two sentences why both Tags.of and the stack tags prop are needed under the explicitStackTags flag.
Before merging, a reviewer decides whether a missing tag value should fail synth or default, checks the key names against the organisation's tagging policy, and confirms that resources CloudFormation cannot tag, such as API Gateway methods, are the only ones without tags in the template. Adding a tag-enforcement aspect that fails synth for untagged resources, or wiring the values from a CI variable, is a follow-up on the same session.
Run it on every Linear issue labelled agent
Sign in to Linear once with POST /me/connections {"type": "app", "name": "linear"} and finish the authorize URL in the console. Then add an automation to the Project with this prompt and a linear trigger on the label you triage with. The trigger adds the issue after the prompt, so the required keys and their sources come from the issue text; the automation's max_runs_per_hour caps how many issues it takes on.
Each labelled issue runs in its own sandbox and opens its own pull request. Once the tags module exists, a later issue such as add a DataClassification tag to the table only runs against the same app, extends the module or applies Tags.of to one construct, and the assertion test grows by one expectation.
The use case this job follows, with its automation and trigger: Turn a Linear label into a PR.
Why run it on Rush?
Tagging in CDK looks like one line and is not, because the context flags in cdk.json decide whether the stack is tagged, aspects decide the order, and CloudFormation decides which resource types can carry tags at all. The only honest check is to synthesize and read the template, then assert on it so it stays true. The agent does that in its own sandbox with the repository's own build and synth scripts before the pull request exists.
The record is the argument. The transcript shows the agent reading explicitStackTags, choosing to tag both the app and the stack, the synthesized template with each key counted, and the test that will fail the next time someone adds an untagged construct. A reviewer who wants a different key or a default value says so in a follow-up and the parked sandbox re-synthesizes in seconds.
Frequently asked questions
Why tag both the app and the stack?
Because cdk.json sets explicitStackTags to true, which stops Tags.of on the app from reaching the CloudFormation stack itself. Tags.of puts the keys on every taggable resource in the template, and the stack's tags prop gives CloudFormation the stack-level tags it propagates and that cost allocation reads.
Where do the tag values come from?
From CDK context: an entry in cdk.json for the defaults, or a -c flag on cdk synth and cdk deploy per environment. A required key with no value throws at synth with the key named, which the pull request explains, so a deploy cannot go out half tagged.
Which resources will not get tags?
Only types CloudFormation cannot tag, such as API Gateway methods and integrations and IAM policies. The test asserts on the table, the five functions and the REST API, and the synth step counts the keys in the template so the untagged types are visible in the description.
Does this need AWS credentials?
No. cdk synth with the repository's fake context file, the same one the pull request build uses, produces the template offline, and the jest test synthesizes in memory. Deploying is the reviewer's step.
Will the test keep working after the next aws-cdk-lib bump?
Yes. It asserts on resource properties through the assertions module rather than snapshotting the whole template, so a library bump that changes an unrelated property or logical id does not fail it. Only a missing tag does.
More AWS CDK jobs
The same job on other stacks
More jobs like this: Turn a Linear label into a PR
- Add a JSON REST API to a CakePHP App (CakePHP)