Kiro × Agentic AI Lens
Engineering teaching aid · 20 min

Using Kiro to Implement the AWS Well-Architected Agentic AI Lens

Best-practice documents tell you what good looks like. They don't enforce it. This session shows how to encode the Agentic AI Lens into Kiro's control surface so that compliance becomes a side effect of normal development — not a separate review step someone forgets.

6 pillars 4 Kiro control mechanisms 150 best practices mapped Author-time → runtime

A walkthrough for engineers building quality-first, Well-Architected agents on Kiro.

The problem

Why best practices don't stick

A recommendation like "implement tool authorization with least-privilege scoping" is unambiguous. But without enforcement at authoring time, it depends on every developer remembering to apply it to every feature, in every sprint, forever.

Runtime guardrails alone

Bedrock Guardrails, IAM policies, CloudWatch alarms — they catch problems after the agent is built. The bad pattern already shipped; you're detecting it, not preventing it.

Author-time controls (Kiro)

Steering, specs, hooks, and permissions shape the code as it's written. The bad pattern never gets authored in the first place. This is the layer the Lens assumes but doesn't give you a tool for.

The key insight for today: agentic systems need controls at authoring time, not just at runtime. Kiro is where you install them.
The Lens in 60 seconds

Six pillars, adapted for agents

The Agentic AI Lens extends the Well-Architected Framework for systems that reason, act autonomously, behave stochastically, collaborate, and remember.

OPS

Operational Excellence

Prompt lifecycle, behavioral monitoring, human-in-the-loop governance.

SEC

Security

Agent identity, tool authorization, data-flow protection, prompt-injection defense, privilege-escalation prevention.

REL

Reliability

Predictable execution, automatic failure recovery, graceful degradation under adverse conditions.

PERF

Performance Efficiency

Cognitive-pipeline optimization, model selection, memory access, multi-agent coordination.

COST

Cost Optimization

Cost as a primary design input, right-sizing model & memory, full cost visibility.

SUS

Sustainability

Modular, reusable architectures; resource efficiency; sustainable adoption.

Kiro's control surface

Four mechanisms that enforce the Lens

Each maps directly onto a control the Lens asks for. Examples target Kiro CLI 3.0 / IDE 1.0.

1

Steering files

Markdown in .kiro/steering/ that gives Kiro persistent standards. Four inclusion modes:

  • always — loaded every session
  • fileMatch — when matching files are in context
  • manual — on-demand via /filename
  • auto — loaded when the request matches its description (like a skill) — ideal for guardrail files

Custom agents load steering only if you add file://.kiro/steering/**/*.md to resources. Global/team steering lives in ~/.kiro/steering/.

2

Spec-driven development

A three-phase workflow with a review checkpoint at each gate:

  • requirements.md — the what, in EARS format
  • design.md — the how: architecture, model rationale, cost estimate, rollback
  • tasks.md — sequenced steps with tests interleaved

Forces explicit thinking about acceptance criteria, failure modes, and security boundaries before any code exists.

3

Agent hooks

Standalone JSON in .kiro/hooks/*.json. A trigger, optional matcher, and an action (shell command or agent prompt). Key triggers:

  • PreToolUse — before a tool runs; can block
  • PostToolUse — after, with tool results
  • SessionStart, Stop, UserPromptSubmit, file-change triggers (CLI V3)

matcher takes categories (read/write/shell/web/spec) or selectors (@mcp, @<server>).

4

Permissions + MCP

Capability-based least-privilege. Rules carry a capability, a match, and an effect — and there are three, evaluated deny-overrides:

  • deny > ask > allow
  • ask is the native human-in-the-loop primitive

MCP (mcpServers) gives explicit, scoped tool access instead of blanket capabilities.

In practice

What the controls actually look like

Three representative artifacts: a steering standard, a blocking hook, and a least-privilege config that pauses for a human on risky writes.

.kiro/steering/security-guardrails.md  ·  Security
# Security Guardrails

## Tool Authorization
- Agents MUST NOT be granted blanket access to all tools.
- Mutating operations (write, delete, update) MUST require human approval
  (enforce with an `ask` effect in the permissions model, not prose alone).
- Tool invocations MUST propagate user identity context.

## Prompt Injection Defense (defense-in-depth)
- Treat input delimiting as ONE layer, not the primary control.
- Never embed raw user input directly into tool invocation parameters.
- The agent itself is NOT a trust boundary: validate memory reads,
  tool I/O, and agent-to-agent messages alike.
.kiro/hooks/scan-credentials.json  ·  PreToolUse — blocks the write
{
  "version": "v1",
  "hooks": [{
    "name": "scan-credentials",
    "trigger": "PreToolUse",
    "matcher": "write",
    "action": { "type": "command",
      "command": "bash .kiro/scripts/scan-credentials.sh" },
    "timeout": 15,
    "enabled": true
  }]
}
Watch the file enumeration. A plain git diff omits untracked files — exactly the case when the agent just generated a new file. Use git ls-files --modified --others --exclude-standard so new files are scanned. And treat the regex as a placeholder — call a real scanner (gitleaks, trufflehog, detect-secrets) for the actual gate.
agent config  ·  least-privilege with ask on risky writes
{
  "name": "customer-service-agent",
  "tools": ["read", "write", "shell"],
  "permissions": { "rules": [
    { "capability":"fs_read",  "match":["src/**"],             "effect":"allow" },
    { "capability":"fs_read",  "match":[".env","secrets/**"], "effect":"deny"  },
    { "capability":"fs_write", "match":["src/**"],             "effect":"allow" },
    { "capability":"fs_write", "match":["migrations/**"],      "effect":"ask"   },
    { "capability":"shell",    "match":["rm -rf*","sudo *"],  "effect":"deny"  }
  ]}
}
Make it auditable

Pillar → Lens best practice → Kiro control → runtime

Leaf best-practice IDs are from the Lens's own Appendix A (41 questions, 150 practices). The priority column carries the Lens's own risk rating — encode the High-rated controls first.

PillarRepresentative best practicesKiro author-time controlRuntimePriority
Operational Excellence AGENTOPS01-BP01/02 roles & handoffs; OPS05-BP01/03 tracing & logging; OPS06-BP01/02 testing & evaluation Specs define roles; steering mandates structured logs + X-Ray IDs; PostToolUse observability + eval hooks AgentCore Observability & Evaluations All High
Security AGENTSEC02-BP01 tool authz; SEC03-BP02/03 identity & least-priv; SEC04-BP02 HITL; SEC08-BP01/02 I/O validation; SEC01 memory Permissions (ask on mutations); scoped MCP; steering; PreToolUse credential scan (blocks) AgentCore Identity & Policy; Bedrock Guardrails All High
Reliability AGENTREL02-BP01/02/04/05 atomic tasks, least-priv, protocols, tiered oversight; REL06-BP02/04; REL07-BP02 Specs capture EARS criteria (circuit breaker, fallback model, retries, idempotency); property-based test hooks AgentCore Runtime; model fallback chains High · 2 Med
Performance Efficiency AGENTPERF02-BP02/04 model selection & TTFT; PERF01-BP03 latency; PERF03-BP02 context; PERF05-BP02 multi-agent Steering sets model principles & latency budgets; design.md budgets; PostToolUse perf hook AgentCore Runtime & Memory All High
Cost Optimization AGENTCOST02-BP01/02/03 tiering, tokens, caching; COST03-BP02 pruning; COST05-BP01/02 attribution Steering token budgets + explicit max_tokens; design.md cost section; agent_id tagging AgentCore Observability; cost allocation tags High · 2 Med
Sustainability AGENTSUS01-BP05 spec-driven tasks for long-running agents; SUS01-BP01/02; SUS03-BP03/04 The spec workflow itself (documented, modular boundaries); steering drives reuse Shared libraries / base class; portfolio governance High · 2 Med
A quiet endorsement: AGENTSUS01-BP05's title literally recommends "specification-driven tasks for frontier agents and long-running workflows" — the Lens has a named best practice for exactly the approach this session is built on. And of everything mapped here, nothing is rated Low: every control is High or Medium priority in the Lens's own eyes.
At a glance

Best practices encoded, by pillar

The practices this session wires into Kiro, split by the Lens's own risk rating. Most are High — the handful of Mediums sit in Reliability, Cost, and Sustainability. Start where the bars are tallest and darkest.

Counts reflect the leaf best practices referenced in the mapping matrix above, rated per Lens Appendix A. Not the full 150-practice set.

The full picture

Kiro is one layer of a closed loop

Kiro owns author-time. The Lens spans the whole lifecycle — and the layers reinforce each other.

Author-time

Kiro

Steering, specs, hooks, property-based tests. Prevents bad patterns from being written.

steering · specs · hooks
Build-time

CI/CD

The same hook scripts run as merge gates. In headless runs, every ask becomes deny — a run does only what's explicitly allowed.

policy presets
Inference-time

Bedrock Guardrails

Content filters, denied topics, contextual grounding. Catches runtime violations.

guardrails
Operations

Monitor & learn

Incident investigation on deployed agents feeds lessons back into steering & specs.

observability

↺ Build in Kiro → enforce at runtime → detect in ops → feed fixes back into Kiro.

Each Kiro standard has a runtime home in AgentCore

The standard you write once in Kiro is enforced at runtime by a specific service — that's what makes the loop genuinely closed rather than aspirational.

Observability steering (structured logs, X-Ray, audit trails)
→
AgentCore Observability
Identity propagation; separate agent/human permissions
→
AgentCore Identity
Least-privilege rules; tool authorization; scoped MCP
→
AgentCore Policy + Gateway
Memory-governance steering (classification, scoping, pruning)
→
AgentCore Memory
Evaluation gate from reliability/ops criteria
→
AgentCore Evaluations
Input validation, output filtering, injection defense
→
Bedrock Guardrails
Live walkthrough

Building a Lens-compliant agent from scratch

The demo arc — a customer-service agent, end to end in Kiro.

Set up steering files

Drop the Lens-aligned templates into .kiro/steering/. Trust the workspace so they load. Every suggestion Kiro now makes respects the guardrails.

Create the spec

Prompt the feature. Kiro generates requirements.md (EARS criteria for reliability, security, observability), design.md (model rationale, latency & cost, rollback), and tasks.md — all shaped by the steering.

Implement with hooks active

As code is generated, the PreToolUse credential scanner blocks on a detected secret, and the PostToolUse observability hook flags any file missing structured logging.

Property-based testing + evaluation

Generate property tests from the reliability criteria (oversized inputs, timeouts, malformed responses) — and add an evaluation gate for the stochastic behavior that assertions can't pin down.

Result: by the time the feature is done it's Lens-aligned by construction — observability instrumented, tool access scoped, mutations gated, degradation tested, model justified, cost estimated, architecture modular. Controls were applied during development, not bolted on in review.
Walk away with this

Three things to remember

Shift controls left

Runtime guardrails detect; author-time controls prevent. Kiro installs the Lens where code is written.

ask is the HITL gate

"Mutations require approval" is a prose wish until it's an ask rule in the permissions model. Make the control real.

Start with one of each

One steering file (security-guardrails.md) and one hook (the credential scanner). Add a pillar per sprint.

Install Kiro & trust your project

So steering and hooks load.

Generate baseline steering

product.md, tech.md, structure.md for context.

Add security-guardrails.md + the credential-scan hook

Highest value-to-effort. Point the hook at a real scanner.

Iterate — a pillar per sprint

Within a few sprints the workflow enforces Lens alignment by default, and new joiners inherit it.