Code Quality Standards

This document defines the required comment, consistency, and technical-debt controls for the okso repository.

Scope

These rules apply to:

File header requirements

src/ and scripts/

Shell files in src/ and scripts/ (*.sh and src/bin/okso) must include these first lines:

#!/usr/bin/env bash
# shellcheck shell=bash
# One-line purpose.
# Usage: ...

tests/

Shell tests and fixtures in tests/ (*.sh) must include at least:

#!/usr/bin/env bash
# shellcheck shell=bash
# One-line purpose.

Bats files may use #!/usr/bin/env bats and still require # shellcheck shell=bash and a one-line purpose line.

Function docblock requirements (src/lib/**)

Shared functions in src/lib/** must include a concise docblock directly above the function with:

Template:

# One-line summary.
# Arguments:
#   $1 - ...
# Returns:
#   stdout/side effects/exit code semantics.

Suppression policy (shellcheck disable)

Every shellcheck disable directive must include:

Valid format:

# shellcheck disable=SC2034 # TD-001: variable intentionally consumed by sourced test harness.

Rules:

Marker-token policy

Unresolved authoring markers are prohibited outside explicitly approved examples:

CI policy

The following commands are required pre-PR and are enforced by CI:

find src scripts tests -type f \( -name '*.sh' -o -name 'okso' \) -print0 | xargs -0 shfmt -d
bash ./scripts/ci/run-shellcheck.sh
bash ./scripts/ci/run-bats.sh
bash ./scripts/ci/check-docs.sh
bash ./scripts/ci/audit-comments.sh
bash ./scripts/ci/audit-consistency.sh

Enforcement level