← 返回博客
AI IDE 指南10分钟阅读

AWS Kiro IDE 2026:规范驱动开发完整指南

Evergreen Tools Team

AWS Kiro 是亚马逊推出的规范驱动 AI IDE,它将 AI 编码从「提示-祈祷」模式转变为结构化工程流程。通过 Specs、Hooks 和 Steering Files 三大核心机制,Kiro 确保 AI 生成的代码始终符合需求、设计和最佳实践。本指南将带你深入掌握 Kiro 的完整工作流。

AWS Cloud Development

什么是规范驱动开发?

传统的 AI 编码工作流是「写提示 → 生成代码 → 祈祷它能用」。这种方式的问题在于: - AI 可能误解需求 - 生成的代码可能偏离设计意图 - 缺乏可追溯性和问责机制 **Kiro 的规范驱动方法**将开发过程分为三个明确的阶段: 1. **需求规范(Requirements Spec)** — AI 帮你将模糊的想法转化为结构化的需求文档 2. **设计文档(Design Doc)** — 基于需求生成详细的技术设计方案 3. **任务列表(Task List)** — 将设计拆解为可执行的具体任务 每个阶段都有人工审查点,确保 AI 始终在正确的轨道上。 使用我们的 [JSON 格式化工具](/en/tools/json-to-yaml) 来结构化你的配置文件。

核心机制:Specs、Hooks 和 Steering Files

**1. Specs(规范文件)** Specs 是 Kiro 的核心。每个功能开发都从创建 Spec 开始: ```yaml # .kiro/specs/user-authentication.yaml name: User Authentication System status: approved created: 2026-07-25 requirements: - id: REQ-001 description: Users must be able to register with email and password priority: must_have acceptance_criteria: - Email validation with RFC 5322 compliance - Password minimum 8 characters, max 128 - Unique email constraint - id: REQ-002 description: Support OAuth2 with Google and GitHub priority: should_have acceptance_criteria: - Google OAuth2 flow complete - GitHub OAuth2 flow complete - Account linking for existing users design: architecture: "JWT-based stateless authentication" database: "PostgreSQL with users table" security: "bcrypt password hashing, rate limiting on auth endpoints" tasks: - id: TASK-001 title: "Create User model and database migration" spec_ref: REQ-001 estimated_effort: "2 hours" status: completed - id: TASK-002 title: "Implement registration endpoint" spec_ref: REQ-001 depends_on: TASK-001 estimated_effort: "3 hours" status: in_progress ``` **2. Hooks(钩子系统)** Hooks 是在代码生成前后自动执行的检查点: ```typescript // .kiro/hooks/pre-generation.ts import { Hook, HookContext } from '@kiro/sdk'; export default new Hook({ name: 'validate-spec-compliance', trigger: 'before-code-generation', async execute(context: HookContext) { const spec = await context.getSpec(); const proposedCode = context.getProposedCode(); // Check if code addresses all requirements const uncoveredReqs = spec.requirements.filter( req => !context.codeAddresses(proposedCode, req) ); if (uncoveredReqs.length > 0) { return { action: 'block', reason: `Missing implementation for: ${uncoveredReqs.map(r => r.id).join(', ')}` }; } return { action: 'allow' }; } }); // .kiro/hooks/post-generation.ts export default new Hook({ name: 'auto-test-generation', trigger: 'after-code-generation', async execute(context: HookContext) { const spec = await context.getSpec(); const code = context.getGeneratedCode(); // Auto-generate tests based on acceptance criteria for (const req of spec.requirements) { for (const criteria of req.acceptance_criteria) { await context.generateTest({ requirement: req.id, criteria, code }); } } return { action: 'continue' }; } }); ``` **3. Steering Files(引导文件)** Steering Files 定义项目的编码规范和 AI 行为约束: ```markdown <!-- .kiro/steering/project-standards.md --> # Project Standards ## Code Style - Use TypeScript strict mode - Prefer functional patterns over classes - Maximum function length: 30 lines - All public APIs must have JSDoc comments ## Architecture - Follow hexagonal architecture - Business logic in /domain layer - External integrations in /infrastructure layer - No circular dependencies ## AWS Integration - Use AWS CDK for infrastructure - All services must have CloudWatch alarms - Use Step Functions for complex workflows - Prefer managed services over self-hosted ## Security - No secrets in code — use AWS Secrets Manager - All API endpoints require authentication - Input validation on all user-facing endpoints ``` 使用我们的 [HTML 转 Markdown 工具](/en/tools/html-to-markdown) 来编写文档。
Development Dashboard

Kiro vs Cursor vs Claude Code

| 特性 | Kiro | Cursor | Claude Code | |------|------|--------|-------------| | **开发方法** | 规范驱动 | 提示驱动 | 提示驱动 | | **需求追踪** | 内置 Spec 系统 | 无 | 无 | | **自动测试** | Hooks 自动生成 | 手动 | 手动 | | **AWS 集成** | 原生深度集成 | 基础 | 基础 | | **企业合规** | GovCloud 支持 | 无 | 无 | | **价格** | 免费 + Bedrock 用量 | $20/月 | $20/月 | **Kiro 的独特优势**: 1. **规范驱动** — 从需求到代码的可追溯链路 2. **AWS 原生** — 深度集成 CDK、CloudFormation、Lambda 3. **企业合规** — 支持 GovCloud 和受监管行业 4. **Hooks 系统** — 自动化的质量保障机制 使用我们的 [XML 转 JSON 工具](/en/tools/xml-to-json) 来处理配置文件。

快速上手

```bash # 1. 安装 Kiro IDE(基于 VS Code) # 从 https://kiro.dev 下载 # 2. 初始化项目 $ kiro init my-project $ cd my-project # 3. 创建第一个 Spec $ kiro spec create "User Authentication" # Kiro 会引导你完成: # 1. 需求收集(AI 辅助) # 2. 设计文档生成 # 3. 任务列表拆解 # 4. 开始编码 $ kiro code --spec user-authentication # 5. 运行 Hooks 检查 $ kiro hooks run ``` ```typescript // Kiro 生成的代码示例(基于 Spec) // src/domain/auth/register-user.ts import { UserRepository } from '../../infrastructure/user-repository'; import { PasswordHasher } from '../../infrastructure/password-hasher'; import { EmailValidator } from '../../infrastructure/email-validator'; import { RegisterUserCommand } from './commands'; import { User } from './entities'; /** * Register a new user * Spec: REQ-001 * Acceptance: Email validation, password requirements, unique constraint */ export async function registerUser( command: RegisterUserCommand, deps: { userRepository: UserRepository; passwordHasher: PasswordHasher; emailValidator: EmailValidator; } ): Promise<User> { // Validate email (RFC 5322) if (!deps.emailValidator.isValid(command.email)) { throw new InvalidEmailError(command.email); } // Validate password (8-128 chars) if (command.password.length < 8 || command.password.length > 128) { throw new InvalidPasswordError('Password must be 8-128 characters'); } // Check uniqueness const existing = await deps.userRepository.findByEmail(command.email); if (existing) { throw new EmailAlreadyExistsError(command.email); } // Create user const hashedPassword = await deps.passwordHasher.hash(command.password); const user = User.create({ email: command.email, passwordHash: hashedPassword, }); await deps.userRepository.save(user); return user; } ``` 使用我们的 [密码生成器](/en/tools/password-generator) 来测试密码策略。
Code Structure

常见问题

Kiro 是免费的吗?

Kiro IDE 本身是免费的(freemium 模式)。你只需为使用的 AWS Bedrock 模型付费。也有免费额度可用于评估。

Kiro 只能用于 AWS 项目吗?

不是。虽然 Kiro 对 AWS 有深度集成优势,但它支持任何技术栈。Spec-driven 方法适用于所有项目类型。

Amazon Q Developer 会怎样?

Amazon Q Developer 的支持将于 2027 年 4 月结束。AWS 建议迁移到 Kiro,它提供了更强大的规范驱动工作流。

Kiro 支持哪些 AI 模型?

Kiro 基于 AWS Bedrock,支持 Claude 3.5 Sonnet、Claude Opus、Titan 等模型。你也可以通过自定义端点接入其他模型。

如何将现有项目迁移到 Kiro?

运行 kiro init --migrate 即可。Kiro 会分析现有代码,自动生成 Steering Files 和基础 Specs。

结论

AWS Kiro 代表了 AI 编码工具的一个重要演进方向:从「提示驱动」到「规范驱动」。通过 Specs、Hooks 和 Steering Files 三大机制,Kiro 让 AI 生成的代码更加可预测、可追溯和可审计。对于 AWS 生态系统的团队和企业级应用来说,Kiro 是目前最值得尝试的 AI IDE。

想要更多开发工具?

探索我们 530+ 免费在线工具,助力你的开发工作流。

浏览工具