---
_version: '1'
uuid: 7215cbf4-085f-421e-b75c-13e78ceaa913
created: 2025-11-14T08:33:55.407483663Z
parents:
- uuid: 007f03ec-58ff-4cfb-b305-58fcf46be529
fingerprint: c5db45893063b61971768b3aeca06ed33229eff5664f3ad87ee294eb970cb5f4
hrid: USR-006
- uuid: 4bfeb7d5-d168-44a7-b0f1-e292c1c89b9a
fingerprint: 084b8ef4e4bf7916248c1e69e61d9c261fc3341ac5feccc33d525ab33de11fd8
hrid: USR-001
---
# SYS-022 Add Requirement Command
## Statement
The tool shall provide a `req add` command that creates new requirement files with automatically assigned sequential IDs, optional template application, and support for inline content specification.
## Rationale
Creating requirements manually is error-prone: engineers must calculate the next ID, create proper directory structure, initialize frontmatter with correct format and UUID, and ensure HRID appears in the title. Automating this workflow prevents formatting errors, ensures ID uniqueness, and applies templates consistently.
This supports USR-001 (plain-text storage) by making requirement creation simple while maintaining proper format, and USR-006 (templates) by automatically applying kind-specific templates.
## Implementation Notes
- Command syntax: `req add <KIND> [--parent HRID...] [--title TEXT] [--body TEXT]`
- Automatically assigns next sequential ID for the given KIND
- Generates UUID v4 for the new requirement
- Sets created timestamp to current time
- Applies template from `.req/templates/<KIND>.md` if available
- CLI flags (`--title`, `--body`) override template content
- `--parent` flag establishes parent links at creation time
- Saves file according to current directory mode configuration
- Reports created HRID to user
- Implemented in `src/cli.rs` lines 127-174
## Verification
- Command creates valid requirement file with correct structure
- IDs increment sequentially within each KIND
- Templates applied when available
- CLI flags override template content
- Parent links established correctly in frontmatter
- HRID appears as first token in title
- File saved to correct location based on configuration mode
- No UUID collisions
- Generated files parse successfully with `req` commands