EARS标准
EARS是需求工程里的一个写需求的标准格式全称是Easy Approach to Requirements Syntax意思是一种“简单的需求语法方法”用于把自然语言需求写成结构统一、歧义更少、适合开发实现的格式。它最早由Rolls‑Royce plc在复杂系统航空、嵌入式软件需求工程中推广现在在软件开发、AI辅助开发、系统工程里非常常见。一、EARS 的核心思想EARS 的目标只有三个1️⃣消除模糊需求2️⃣统一需求句式3️⃣让开发和 AI 都能理解普通 PRD 的问题用户可以上传图片。 系统需要快速处理。 当网络不好时最好提示用户。问题“可以” 是不是必须“快速”是多少“最好提示”是不是必须EARS 会改写为When the user uploads an image, the system shall process the image within 3 seconds.特点条件触发系统行为结构非常清晰。二、EARS 的 5 种标准句式EARS 一共有5 种需求结构。1 普通需求Ubiquitous Requirement最基础需求。格式The system shall action.例子The system shall store user profile information.中文系统必须存储用户资料信息。2 条件需求Event Driven Requirement某个事件触发。格式When event, the system shall action.例子When the user taps the upload button, the system shall start uploading the file.中文当用户点击上传按钮时系统必须开始上传文件。3 状态需求State Driven Requirement某种状态下触发。格式While state, the system shall action.例子While the device is offline, the system shall store requests locally.中文当设备处于离线状态时系统必须本地缓存请求。4 可选需求Optional Requirement某个功能可能存在。格式Where feature enabled, the system shall action.例子Where dark mode is enabled, the system shall display dark theme UI.中文当暗黑模式开启时系统必须显示暗色UI。5 异常需求Unwanted Behaviour错误处理。格式If error condition, the system shall response.例子If the upload fails, the system shall display an error message.中文如果上传失败系统必须显示错误提示。三、EARS 的标准结构一个完整需求通常包含condition system shall action constraint例子When the user starts recording, the system shall capture audio at 16kHz mono.这个就很适合你的音频项目四、为什么 AI 开发喜欢 EARS你现在在做ClaudeAI codingspec驱动开发EARS 非常适合 AI。原因1️⃣结构固定AI容易理解2️⃣减少歧义LLM最怕模糊需求3️⃣方便自动生成代码例如When the user presses record, the system shall start audio capture using AudioQueue.Claude 可以直接生成AudioQueueStart(...)五、PRD → EARS 示例原 PRD用户可以录音并且可以暂停和继续录音。 如果录音失败要提示。EARS 写法When the user presses the record button, the system shall start audio recording. When the user presses the pause button, the system shall pause the recording. When the user presses the resume button, the system shall resume the recording. If audio recording fails, the system shall display an error message.六、EARS 在 AI Spec 开发里的用法很多 AI 开发流程PRD ↓ EARS需求 ↓ Spec文档 ↓ AI生成代码比如/spec upload.ears.md audio_record.ears.mdClaude 提示Implement requirements in audio_record.ears.mdAI就会按需求写代码。七、EARS 的一句话总结EARS 用固定语法写需求。核心句式When/If/While/Where ... the system shall ...AI Coding Spec 目录spec/ ├── 01_prd.md ├── 02_ears_requirements.md ├── 03_api_spec.md ├── 04_data_model.md ├── 05_ui_spec.md └── 06_tasks.md
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2409523.html
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!