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.
A walkthrough for engineers building quality-first, Well-Architected agents on Kiro.
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.
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.
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 Agentic AI Lens extends the Well-Architected Framework for systems that reason, act autonomously, behave stochastically, collaborate, and remember.
Prompt lifecycle, behavioral monitoring, human-in-the-loop governance.
Agent identity, tool authorization, data-flow protection, prompt-injection defense, privilege-escalation prevention.
Predictable execution, automatic failure recovery, graceful degradation under adverse conditions.
Cognitive-pipeline optimization, model selection, memory access, multi-agent coordination.
Cost as a primary design input, right-sizing model & memory, full cost visibility.
Modular, reusable architectures; resource efficiency; sustainable adoption.
Each maps directly onto a control the Lens asks for. Examples target Kiro CLI 3.0 / IDE 1.0.
Markdown in .kiro/steering/ that gives Kiro persistent standards. Four inclusion modes:
always — loaded every sessionfileMatch — when matching files are in contextmanual — on-demand via /filenameauto — loaded when the request matches its description (like a skill) — ideal for guardrail filesCustom agents load steering only if you add file://.kiro/steering/**/*.md to resources. Global/team steering lives in ~/.kiro/steering/.
A three-phase workflow with a review checkpoint at each gate:
requirements.md — the what, in EARS formatdesign.md — the how: architecture, model rationale, cost estimate, rollbacktasks.md — sequenced steps with tests interleavedForces explicit thinking about acceptance criteria, failure modes, and security boundaries before any code exists.
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 blockPostToolUse — after, with tool resultsSessionStart, Stop, UserPromptSubmit, file-change triggers (CLI V3)matcher takes categories (read/write/shell/web/spec) or selectors (@mcp, @<server>).
Capability-based least-privilege. Rules carry a capability, a match, and an effect — and there are three, evaluated deny-overrides:
deny > ask > allowask is the native human-in-the-loop primitiveMCP (mcpServers) gives explicit, scoped tool access instead of blanket capabilities.
Three representative artifacts: a steering standard, a blocking hook, and a least-privilege config that pauses for a human on risky writes.
# 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.
{
"version": "v1",
"hooks": [{
"name": "scan-credentials",
"trigger": "PreToolUse",
"matcher": "write",
"action": { "type": "command",
"command": "bash .kiro/scripts/scan-credentials.sh" },
"timeout": 15,
"enabled": true
}]
}
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.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" }
]}
}
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.
| Pillar | Representative best practices | Kiro author-time control | Runtime | Priority |
|---|---|---|---|---|
| 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 |
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.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.
Kiro owns author-time. The Lens spans the whole lifecycle — and the layers reinforce each other.
Steering, specs, hooks, property-based tests. Prevents bad patterns from being written.
steering · specs · hooksThe same hook scripts run as merge gates. In headless runs, every ask becomes deny — a run does only what's explicitly allowed.
Content filters, denied topics, contextual grounding. Catches runtime violations.
guardrailsIncident 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.
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.
The demo arc — a customer-service agent, end to end in Kiro.
Drop the Lens-aligned templates into .kiro/steering/. Trust the workspace so they load. Every suggestion Kiro now makes respects the guardrails.
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.
As code is generated, the PreToolUse credential scanner blocks on a detected secret, and the PostToolUse observability hook flags any file missing structured logging.
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.
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.
One steering file (security-guardrails.md) and one hook (the credential scanner). Add a pillar per sprint.
So steering and hooks load.
product.md, tech.md, structure.md for context.
security-guardrails.md + the credential-scan hookHighest value-to-effort. Point the hook at a real scanner.
Within a few sprints the workflow enforces Lens alignment by default, and new joiners inherit it.