| name | veto-implement-feature |
| description | Implement a feature or fix using TDD workflow in the veto Rust codebase. Use this skill whenever the user asks to: add a new rule category, implement a CLI subcommand, add an auth method, modify the risk engine, add a new integration (setup command), or write Rust code for veto. This skill enforces test-first development and follows veto's module conventions. If the request involves writing Rust code and tests, use this skill. |
| argument-hint | [spec-file-path | feature description] |
| targets | ["claude"] |
Implement a feature following TDD workflow. $ARGUMENTS is a spec file path or a plain-text feature description.
Scope: This skill writes Rust code and tests. It does NOT update docs (update README manually if needed).
Workflow
Step 1: Understand Requirements
If $ARGUMENTS is a file path:
- Read the spec file
- Extract acceptance criteria and edge cases
- Identify affected modules
If $ARGUMENTS is a description:
- Search existing code for related functionality
- Identify the right module to extend
- Confirm scope with user before proceeding
Step 2: Identify Affected Files
Map the feature to veto's module structure:
src/
āāā main.rs # Entry point
āāā cli/mod.rs # Clap CLI definitions
āāā config/
ā āāā mod.rs # Config module root
ā āāā types.rs # Config structs
ā āāā loader.rs # Config file loading
āāā rules/
ā āāā mod.rs # Rules module root
ā āāā types.rs # Rule, Rules, Whitelist structs
ā āāā engine.rs # Risk evaluation engine
ā āāā defaults.rs # Built-in rule patterns
āāā executor/
ā āāā mod.rs # Command execution
ā āāā shell.rs # Shell interaction
āāā auth/
ā āāā mod.rs # Auth module root
ā āāā manager.rs # Auth method dispatch
ā āāā pin.rs # PIN auth
ā āāā totp.rs # TOTP auth
ā āāā touchid.rs # macOS Touch ID
ā āāā telegram.rs # Telegram bot auth
ā āāā keyring.rs # System keychain
ā āāā challenge.rs # Challenge generation
ā āāā confirm.rs # Confirmation prompts
ā āāā dialog.rs # Dialog-based auth
āāā commands/
ā āāā mod.rs # Command dispatch
ā āāā init.rs # veto init
ā āāā doctor.rs # veto doctor
ā āāā setup.rs # veto setup (integrations)
ā āāā shell.rs # veto shell
ā āāā auth.rs # veto auth
ā āāā upgrade.rs # veto upgrade
ā āāā log.rs # veto log
ā āāā allow.rs # veto allow
āāā audit.rs # Audit logging
Step 3: Write Failing Tests First (RED)
Write tests in the relevant module's #[cfg(test)] mod tests:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_feature_basic_case() {
let rules = default_rules();
let engine = RuleEngine::new(&rules);
let result = engine.evaluate("some command");
assert_eq!(result.risk_level, RiskLevel::Critical);
}
}
For integration tests, use assert_cmd in tests/:
use assert_cmd::Command;
use predicates::prelude::*;
#[test]
fn test_check_blocks_dangerous_command() {
Command::cargo_bin("veto")
.unwrap()
.args(&["check", "rm -rf /"])
.assert()
.failure()
.stderr(predicate::str::contains("CRITICAL"));
}
Verify tests fail:
cargo test test_feature_basic_case
Step 4: Implement (GREEN)
Write minimal code to make tests pass:
- Follow existing patterns in each module
- Use
colored crate for terminal output
- Use
thiserror for error types
- Register new CLI commands in
cli/mod.rs (Clap derive)
- Wire command dispatch in
commands/mod.rs
Key patterns:
- Rules: Add patterns to
defaults.rs, types to types.rs, logic to engine.rs
- Auth: Add method to
auth/, register in manager.rs
- Commands: Add handler in
commands/, register in cli/mod.rs
- Config: Add fields to
types.rs, parsing to loader.rs
Verify tests pass:
cargo test
Step 5: Quality Check
make check
Fix any issues before proceeding.
Step 6: E2E Verification
If the feature affects CLI-visible behavior:
- Update
scripts/e2e.sh with new test cases
- Run
make e2e to verify
Step 7: Report
- List all created/modified files
- Confirm each acceptance criterion is met with test evidence
- Show
cargo test output as proof
Rules
- Test-first ā always write failing test before implementation
- Minimal code ā only write what's needed to pass tests
- Follow patterns ā match existing code style in each module
- 3-strike rule ā if a test fails 3 times after fixes, stop and report
- No speculative features ā only implement what's in the spec/description
- Verify with
make check ā must pass fmt, clippy, and all tests