--- # nbd-wi74 title: '''VERSION file: compile into binary via include_str\! and add nbd version subcommand''' status: todo type: feature priority: normal created_at: 2026-03-10T23:30:30Z updated_at: 2026-03-10T23:30:30Z --- ## Problem The current version string is assembled in `main.rs` from `CARGO_PKG_VERSION` (Cargo.toml) and `GIT_SHORT_SHA` (build.rs). There is no `nbd version` subcommand — only `--version`. And the `/work` skill does not bump any version on completion. ## Changes required ### 1. Create `VERSION` file Create a `VERSION` file at the crate root (`nbd/VERSION`) containing the initial version: ``` 0.1.0 ``` ### 2. Use `VERSION` in the binary In `src/main.rs`, replace `CARGO_PKG_VERSION` with an `include_str\!` of the `VERSION` file (trimmed): ```rust const VERSION: &str = concat\!( env\!("CARGO_PKG_VERSION"), // keep for crate metadata "+", env\!("GIT_SHORT_SHA"), ); ``` Actually, use `include_str\!("../VERSION")` trimmed and concatenated with the git SHA: ```rust const VERSION_FILE: &str = include_str\!("../VERSION"); const VERSION: &str = /* VERSION_FILE.trim() + "+" + GIT_SHORT_SHA at runtime or via concat */ ; ``` Note: `include_str\!` and `concat\!` cannot trim at compile time. Use a `build.rs` approach: read `VERSION` in `build.rs`, trim it, and emit it via `cargo:rustc-env=NBD_VERSION=...`. Then: ```rust const VERSION: &str = concat\!(env\!("NBD_VERSION"), "+", env\!("GIT_SHORT_SHA")); ``` Update `build.rs` to read `VERSION` and emit `NBD_VERSION`. ### 3. Add `nbd version` subcommand Add a `Version` variant to the `Commands` enum: ```rust /// Print the nbd version string and exit. Version, ``` Handler prints the same string as `--version`. With `--json`, output `{"version": "X.Y.Z+sha"}`. ### 4. Update `/work` skill Edit `.claude/skills/work/SKILL.md` to add a version-bump step after marking a ticket complete: - Breaking changes (major rework, API change) → bump major: `X.0.0` - Features (`ticket_type == feature`) → bump minor: `X.Y.0` - Tasks and bugs (`ticket_type == task | bug`) → bump patch: `X.Y.Z` The skill should read `VERSION`, parse the semver, increment the appropriate component, and write it back. Also update `Cargo.toml` `version` to match (keep in sync). ## Relevant files - `nbd/VERSION` (new) - `nbd/build.rs` (update: emit `NBD_VERSION`) - `nbd/src/main.rs` (update: use `NBD_VERSION`, add `Version` subcommand) - `nbd/Cargo.toml` (keep version in sync with `VERSION` file) - `.claude/skills/work/SKILL.md` (update: add version-bump step)