去年,我的干女儿突然找到我,说:"爸爸,我需要用 AI 制作一个 2025 年的日历,每一页都要有花。"听起来很简单对吧?但作为一个程序员,我立刻意识到这是一个绝佳的机会来探索 AI 编程的新玩法。
既然要做,就做得彻底一点。我决定不仅仅是完成她的作业,而是要创造一个真正有价值的多语言学习日历网站,同时验证一下 Kiro IDE 的 Spec Coding 功能到底有多强大。
大多数人用 AI 编程都是"vibe coding"——想到什么就让 AI 写什么,没有系统性的规划。但 Kiro IDE 提供了一种全新的方法:Spec Coding。
这种方法让 AI 不再是随意发挥,而是按照工程化的流程来开发软件。
Kiro 帮我用 EARS 模式写出了严格的需求:
### Requirement 1: Calendar Display
**User Story:** As a user, I want to view a complete 2026 calendar, so that I can see dates and plan my activities.
#### Acceptance Criteria
1. THE Calendar_System SHALL display all 12 months of 2026
2. WHEN a user navigates between months, THE Calendar_System SHALL show the correct dates for each month
3. THE Calendar_System SHALL highlight the current date when viewing the current month
每一条需求都有明确的验收标准,这样 AI 就知道要实现什么功能。
Kiro 不仅设计了架构,还定义了正确性属性:
**Property 1: Calendar Month Generation**
*For any* month in 2026, the calendar system should generate a valid month grid with the correct number of days and proper date sequencing
**Validates: Requirements 1.1, 1.2**
**Property 5: Unique Monthly Flowers**
*For any* two different months, they should display different Portuguese flowers, ensuring all 12 months have unique flower assignments
**Validates: Requirements 2.1**
这些属性后来变成了自动化测试,确保代码的正确性。
Kiro 把整个项目分解成了可执行的小任务:
- [ ] 1. Set up project structure and core calendar engine
- [ ] 1.1 Write property test for calendar month generation
- [ ] 2. Implement date display and highlighting features
- [ ] 2.1 Write property test for current date highlighting
每个任务都有明确的验收标准和测试要求。
传统的单元测试只测试几个例子,但 Kiro 帮我实现了属性驱动测试:
// 测试所有月份都有唯一的花
Property: Unique Monthly Flowers
*For any* two different months, they should display different Portuguese flowers
这种测试会生成大量随机输入来验证属性,比传统测试更可靠。
每个月的花都有三种语言的名称:
| 月份 | 葡萄牙语 | 英语 | 中文 |
|---|---|---|---|
| 1 月 | Camélia | Camellia | 山茶花 |
| 2 月 | Flor de Amendoeira | Almond Blossom | 杏花 |
| 6 月 | Alfazema | Lavender | 薰衣草 |
不仅有花,还加入了 2026 年的中国节日:
传统方式:
Spec Coding 方式:
使用 Spec Coding 后:
🌐 网站地址: https://mrfeixiang.github.io/2026/
传统的"vibe coding"适合快速原型,但要做出高质量的软件,还是需要工程化的方法。Kiro IDE 的 Spec Coding 提供了一个很好的框架:
原本只是帮干女儿完成一个简单的作业,最终却创造了一个功能完整的多语言学习平台。这个过程让我深刻体会到了 Spec Coding 的威力。
Kiro IDE 不仅仅是一个 AI 编程工具,更是一个思维方式的转变。它教会我们用工程化的方法来思考问题,用系统性的方式来解决问题。
如果你也想尝试这种新的 AI 编程方式,我强烈推荐试试 Kiro IDE 的 Spec 功能。相信你会和我一样,发现 AI 编程的新境界。
项目链接:
技术栈:HTML5 + CSS3 + Vanilla JavaScript + Kiro IDE Spec Coding
用 AI 编程,但不止于 AI 编程。用工程思维,创造真正的价值。