Skip to main content

code-standards

One deterministic quality gate for Sarj Python, TypeScript, Swift, Kotlin, shell, SQL, IaC, and repository policy.

uv tool install --python 3.15 code-standards

Adopt the repository once with code-standards setup. It installs one canonical staged gate that includes semantic lint and repository policy, plus commit-message and pull-request history enforcement. Do not install Repo Standards separately.

Managed commit hooks advise on subjects over 72 descriptive characters. These warnings preserve message text and validation results. PR CI advises on title and body text without blocking commit policy.

The pre-commit gate runs once on every commit and discovers paths directly from the Git index, including mixed file types and deletion-only commits. The shared dispatcher selects applicable rules and retains type analysis, repository policy, exclusions and suppression accountability. Errors and incomplete analysis block the commit; warning-stage findings stay visible even when the hook passes. Generated hooks apply safe custom-rule, Ruff and Oxlint fixes automatically. When a fix changes a staged file, the gate stops so you can review and stage the edit, then retry. Use code-standards fix --staged to apply fixes separately, or check --fix to fix before checking. Staged fixes never fall back to the whole repository and refuse files with unstaged changes.

Setup installs the selected hook manager. In a fresh checkout, run code-standards doctor --repair before committing; doctor checks installation and the exact unconditional command. Conditional Lefthook jobs must be moved to an unconditional job without changing unrelated hooks. Git can bypass local hooks with --no-verify; the canonical CI gate independently enforces policy.

code-standards setup
code-standards check
code-standards check --rule python:no-excessive-cognitive-complexity src/
code-standards fix
code-standards doctor
code-standards update

TypeScript setup writes oxlint.config.mts, which extends createConfig() from the synced oxlint.strict.mts preset. code-standards update migrates ESLint-era configs, presets, bulk suppressions and disable comments to Oxlint.

To preserve generated source byte-for-byte during setup and update, list its exact file paths in .sarj-standards.toml under [doctor].exclude, for example exclude = ["src/components/ui/stepper.tsx"]. Keep the generated directories in the authored Oxlint ignorePatterns and formatter exclusions as well: native lint/format exclusions alone do not select migration inputs. File-level adoption exclusions preserve security scanning of those files and generated artifacts. Do not use directory-wide [doctor].exclude entries for this purpose, because those also exclude directories from project security discovery. Adjacent authored files still undergo directive migration and validation.

Doctor reads doctor.config.json by default. An authored doctor.config.ts, .mts, .js, .mjs, .cts or .cjs takes precedence, in that order, and must export a configuration object. Use Node-supported module syntax to extend the managed JSON and preserve its ignores and overrides. Executable configs require --trust-repository-code; without it the gate fails before importing the module. Staged checks load the indexed config and its indexed imports.

TypeScript setup also installs Syncpack 15.3.3 and synchronizes syncpack.strict.mts. Import that preset from .syncpackrc.ts, append repository-specific version groups, and run syncpack lint in the repository's existing dependency gate. The preset checks package-manager versions and dependency consistency while preserving hand-managed resolution floors. Setup and doctor detect preset and tool-pin drift. Syncpack remains a separate native gate; code-standards check does not run it.

Use repeatable check --rule ENGINE:ID selectors to select native rules, Oxlint rules, or managed security audits. Exclusions, baselines, and severities still apply; Ruff selectors are not supported. Native linters and Oxlint execute only selected rules. Oxlint retains configured plugins, options, severities, and suppression directives.

To refresh without accepting new debt, save the reviewed consumer baseline unchanged and run code-standards baseline update --budget /path/to/accepted.json. Use that same fixed budget for the full scan and subsequent --rule refreshes on one output artifact. Only existing fingerprints up to their accepted counts enter the refreshed baseline; new and increased findings remain active. Invalid budgets and analysis execution failures prevent writing. Existing review gates still establish whether the selected budget is authorized.

Trusted staged and PR checks preserve existing diagnostic fingerprint/count budgets for Python files whose only changes are descriptions after pre-existing coded inline # type: ignore[...] or # noqa: CODE suppressions. The suppression prefix, target codes, scope, and every other source byte must stay identical. Reasons use — or -- and cannot contain checker pragmas. This is a bounded lexical proof using real comment tokens, not general AST equivalence. Immutable Git inputs and the exact worktree postimage are validated again after comparison. New findings, count growth, and required source policies still fail. Trusted check --staged --fix preserves these proven Python sources without applying unrelated native or Ruff fixes.

For a history-free initial import, set SARJ_STANDARDS_INITIAL_IMPORT_SOURCE only on the initial commit process to the full lowercase object ID of an available source commit with exactly one available parent. HEAD must be an unborn branch; the entire staged tree must equal that commit, tracked worktree files must match the index without hidden index flags, and nonignored files must be staged. Native staged checks compare the source commit with its parent, preserving the usual changed-line failures for findings introduced in that commit while allowing inherited diagnostic budgets. Validation runs before and after analysis; all analyzers and baseline limits still apply. The caller must qualify the source commit separately. Git replacement objects and lazy fetching are disabled; explicitly supplied temporary object alternates may provide the source history without copying it into the new repository. Remove the input and alternates before subsequent commits, pushes, and CI. Invalid or changed import context fails analysis, including clean reports; ordinary checks without this input retain their existing behavior.

Selected Oxlint checks apply live inline and bulk suppressions. The complete lint gate owns unused inline-directive and stale bulk-suppression checks: a partial run cannot establish whether an unselected rule's directive is needed.

The complete Python and JavaScript/TypeScript source gate requires named, line-local exceptions with concrete reasons. SARJ523 rejects blanket Python waivers, scoped Ruff file/range disables and weakened Pyright source settings; SARJ419 also rejects missing explanations. Bare sarj-noqa markers cannot waive Python, SQL or IaC findings. Required Ruff blanket-ignore checks and an independent Oxlint suppression-policy pass remain active despite source disables, consumer rule configuration, rule exclusions and diagnostic baselines. The Oxlint pass bans file/range disables, ts-ignore and ts-nocheck while retaining described local ts-expect-error exceptions. Generated-source headers cannot authorize their own waiver; explicit whole-path exclusions retain that boundary. A reason is not proof that an exception is justified. Native parse/read/size failures make checks incomplete. Explicit tool delegation, partial and own-CI options retain their declared scope and coverage notices.

The complete Standards gate enforces Ruff's ban on typing.cast and typing_extensions.cast even when source comments, consumer Ruff configuration or manifest rule exceptions suppress banned-api; these cast findings cannot enter or consume the diagnostic baseline. Wildcard imports, bounded literal getattr names and proven read-only typing module namespace lookups through __dict__, vars and __getattribute__ retain the same ban. Other banned APIs retain their existing exception policy.

Terraform, Kubernetes, and GitHub Actions adoption adds isolated Checkov 3.3.30 and zizmor 1.31.1 runtimes. Setup and generated CI prewarm these tools; checks run offline with packaged policy. Use --rule checkov:CKV_GCP_95 or --rule zizmor:template-injection to select upstream audits. Their findings start as warnings, use the canonical diagnostic baseline, and retain upstream IDs. Checkov honors its inline suppression directives; zizmor ignore comments are disabled. Explicit zizmor selectors include auditor-persona checks; online-only audits cannot run offline. Parsing or execution failures leave the analysis incomplete. Image digest evidence for source templates is deferred to their rendered deployment artifacts.

The opt-in jscpd capability runs the jscpd 5.4.0 copy-paste detector, which setup installs through mise. Setup and upgrades list it in [capabilities].disable; remove it there to enable it. Each check scans Python, TypeScript, Swift and Kotlin source outside test directories, because a copy can only be found by comparing it with the whole tree. Every repeated block of at least 50 tokens is a jscpd:duplicate-code warning on its own lines that names the other copies, so the changed-line baseline reports it when either side is edited. The repository's own jscpd configuration is ignored.

The shfmt capability checks shell files, including extensionless shebang entrypoints, with shfmt 3.14.1 using two-space indentation and indented case clauses. Explicit, staged and PR-selected files must be formatted in full; full scans report existing drift as warnings. Formatting errors on selected files cannot be hidden by a diagnostic baseline. code-standards fix formats selected files safely, preserving executable permissions; generated Gradle launchers are excluded. Shebangs determine the shell before filename suffixes, including supported shells at custom absolute paths. Bats files use the upstream Bats formatter dialect. Zsh formatting does not provide ShellCheck coverage: its unsupported dialect remains an explicit coverage failure. Ambient editor settings cannot change the canonical style, and simplification is disabled.

Shell libraries with a shell suffix or no suffix can declare their dialect with a top-level # shellcheck shell=bash header before executable source. Quoted dialect values and preceding directive fields are supported. An executable shebang remains authoritative. Generated Gradle exclusions require the exact generator comment in the source header; mentions in strings, heredocs and ordinary prose do not exempt authored scripts. Automatic fixes refuse native formatter output that removes carriage-return bytes, so literal data and line endings need manual review in those cases.

ShellCheck and shfmt also inspect executable shell fields in workflows, composite actions, Cloud Build, Make and Mise using the same policy as shell files. Analysis follows the configured interpreter, including inherited Actions shells and Cloud Build shebangs, and reports positions in the authored configuration. Actions expressions are masked for native parsing with their quoted string boundaries preserved, and actionlint retains workflow validation while shared ShellCheck supplies shell findings once. Docker shell semantics remain owned by Hadolint. Fixes can format verified literal YAML blocks while preserving scalar headers, newlines and decoded execution source. Folded scalars, aliases, templates, argv, Make and Mise remain check-only; extract complex programs to shell files for independently linted execution.

The opt-in knip capability uses Knip 6.48.0 production mode. Remove it from [capabilities].disable and declare application = true under [knip] to enable advisory knip:files evidence. Version one supports a single private application with entry and project arrays containing production patterns ending in ! in knip.json or .knip.json. Native aliases and framework entries remain authoritative; unresolved imports, configuration diagnostics, workspaces and dynamic configuration make the graph inconclusive. Review runtime and public owners before deleting a module. No automatic fixes or application inference are performed.

The opt-in sqlfluff capability checks source-mapped static Python queries with SQLFluff 4.5.0. Remove sqlfluff from [capabilities].disable after reviewing the repository corpus. Only import-proven psycopg receivers establish the SQL boundary. Stable string bindings, closed string additions, and import-proven SQL, Identifier, SQL.format and explicit-list/tuple SQL.join compositions can supply the query. Each rendered fragment maps to its original Python literal; generated identifier quoting anchors to that identifier literal. Mutable composable bindings and join-member containers require a single consumption chain; multiple uses and escapes remain coverage gaps. Class literal recovery is conservative and does not model arbitrary runtime patching. PostgreSQL rules sqlfluff:AM07 and sqlfluff:AM08 reject known set-column mismatches and joins without a condition or explicit CROSS JOIN. Native positional and named psycopg parameters are supported. Findings map to the authored Python source and respect existing manifest rule exclusions. Dynamic expressions, decoded escapes, generators, adaptation through Literal, forwarded wrappers, parser failures and oversized queries remain outside coverage; discovered dynamic or unsupported queries produce a visible coverage notice. The adapter does not execute SQL, load repository SQLFluff configuration or apply fixes. Its isolated parser uses bounded input, output, deadlines and cancellation. New adoptions and upgrades keep it disabled by default.

Unused private Python test helpers require reportUnusedFunction set to warning in the consumer's existing BasedPyright test execution environments. This bundle preserves native configuration and bounds test warnings to authored, undecorated module-level private helpers in conventional test paths. Decorated fixtures, methods and production callbacks are excluded; no consumer diagnostic setting is enabled automatically. Existing production diagnostics are preserved.

check --jobs 2 overlaps native analysis with the external-tool pipeline. The default is --jobs 1; external tools remain sequential and report ordering is deterministic.

Public Python suggested edits retain expected_source_hash, the lowercase SHA-256 digest of the exact captured source bytes, alongside expected_text_hash for the replaced slice. Use to_json(report, include_fix_source_hashes=True) or the same keyword on report, diagnostic, fix or edit as_dict to emit expectedSourceHash. The default JSON output is unchanged. Opted-in JSON requires the updated bundled analysis.schema.json; older strict v1 schemas reject the added field. This provenance does not apply edits or validate a current file, and SARIF output is unchanged.

DevOps execution blocks may sequence existing commands without helper scripts. Keep interpreter source, control flow, logical chains, pipelines and substitutions in independently linted files; Python -m and script paths, and jq/awk -f files remain supported. SARJ310 is an error, including short inline programs. Cloud Build SARJ315 checks YAML and JSON for unique IDs, ordered step dependencies, script/argv exclusivity and untrusted substitutions in shell source; pass substitutions as quoted arguments to external scripts. JSON configs are discovered in operational directories or with cloudbuild in their filename; JSON syntax must be strict, with unique keys and finite numbers. Files named with cloudbuild, and Build-shaped files under a cloudbuild directory, use the bundled, digest-verified Google Build v1 field schema for field names, types, enums and protobuf durations/integers. The offline schema rejects output-only fields; trigger expansion, resource access and hosted admission require the deployment environment.

The source gate uses pinned actionlint, shared ShellCheck, offline Zizmor, Hadolint and Skaffold v4beta7 schema validation. Every selected action.yml/action.yaml uses GitHub's pinned action parser and converter offline, including composite steps, expression syntax and available contexts, runtime requirements, step IDs and action-reference forms. This uses the core Node runtime and needs no referencing workflow, consumer npm setup or security capability. Cloud Deploy validation is a documented partial structural contract. Terraform validation and TFLint require explicit repository trust and prepared local providers; analysis never initializes or downloads them. Immutable legacy guard contracts allow reviewed guard removal after equivalent enforcement is established by its existing owner. Surviving guards must remain exact; edited or new guards, changed contract history and staged/worktree differences still fail. Original guard-source files must remain present. Compose requires an exact consumer [devops].compose_version; its source check does not resolve environment inputs. Declare compose_projects = [["base.yaml", "overlays/production.yaml"]] in [devops] to validate custom filenames and overlays in invocation order. Selecting any member checks the whole project; declared fragments are not checked independently. Undeclared conventional filenames remain standalone projects. Missing inputs and native field errors fail coverage. Source checks use Compose's partially resolved model; full consistency requires the actual deployment environment.

File discovery, enabled capabilities and native validation each determine coverage. Check the selected paths and tool reports; a syntax check does not establish deployment validity.

Format Specialized coverage Boundary
Terraform .tf, .tf.json Native validation, TFLint and applicable Sarj rules Local providers and explicit trust required; JSON is never passed to fmt
.tfvars, .tftest.hcl Native Terraform formatting Variable/test files do not select module validation or TFLint
.tfvars.json, .tftest.json, other .hcl Applicable Sarj rules No native formatting; JSON semantic coverage is limited
Actions workflows and action metadata actionlint for workflows; pinned GitHub action parser for all action.yml/action.yaml files, including composite steps; Zizmor and shared execution checks Offline validation covers structure and expression syntax/contexts; expression values and runtime availability require GitHub; security capabilities may be disabled
Cloud Build YAML/JSON Pinned Google Build v1 field schema, SARJ315 and shared execution checks Schema selection uses a cloudbuild filename or Build-shaped source in that directory; trigger inputs and hosted admission remain external
Dockerfile variants Hadolint and executable-field checks Image-default entrypoints are not inferred
Conventional Compose filenames and declared compose_projects Pinned native Compose validation of ordered file groups Environment interpolation/resolution stays disabled; deployment must supply its actual environment inputs
Skaffold and Cloud Deploy YAML Pinned Skaffold schema; partial Cloud Deploy structure Generated resources need prepared validation
Helm charts, Kubernetes and CRDs Prepared Helm lint/render, kubeconform and kube-linter Receipts must bind the rendered artifacts and local schema closure
Templates, systemd units, Nginx, Kamailio, Prometheus and Compose configs Prepared native validation of rendered files with the matching runtime Declare prepared targets and hash their authored inputs, rendered files and include closure; other service formats need their own application validator

Native prepared targets use kind values systemd, nginx, kamailio, prometheus-config, prometheus-rules or compose, plus native_version, manifests and artifacts. native_version is the exact first version-output line of the installed validator; Nginx writes it to stderr. Compose instead uses its exact semantic version and requires a hashed environment_file; ordered manifests run through native config --quiet with full interpolation and consistency checks. List executable artifacts under executables when unit validation requires them. Render templates first and bind template/variable inputs with source_inputs. The gate verifies hashes, stages a private copy and invokes only the service's check mode. Native service validation requires explicit repository trust and the deployment's matching runtime, including any referenced modules or runtime files; it never installs or starts a service. Systemd disables generators and verifies against the staged root. Other validators may resolve absolute runtime paths on the validation host; this is not a filesystem sandbox.

Release gates use code-standards analyze --prepared-only --prepared-devops prepared.json --prepared-target TARGET_ID; add --trust-repository-code for native service and Compose targets. Declare exact prepared_targets under [devops] with an authored source path. Version-one receipts bind target IDs, authored input hashes, staged chart archives, ordered values, typed set arguments, manifests and a hashed local schema closure. Helm 4.3.1 strict lint and stage-specific rendering feed kubeconform 0.8.0 and kube-linter 0.8.3. Missing tools, schemas, targets and invalid receipts fail the gate. Prepared-only findings bypass source debt baselines; container exceptions require exact target, GVK, namespace, object, check, container kind, container name and a reason, and stale exceptions fail.

Prepared YAML rejects duplicate parsed keys and cyclic aliases. Each document must stay below depth 64 and at or below 100,000 expanded nodes, including repeated aliases.

Source-only checks report prepared validation as deferred. They do not certify generated manifests or replace Cloud Deploy, Cloud Build or Kubernetes admission validation. Run setup --tools-only in CI after installing the bundle and the pinned mise bootstrap. It requires an existing manifest, installs and attests the applicable native tools, and preserves repository wiring. Release analysis consumes prepared bytes without pulling charts.

Documentation · Source

Metadata

Release files for code-standards 9.129.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code-standards 9.129.0
File Size Uploaded Provenance Actions
code_standards-9.129.0.tar.gz 1.5 MB With provenance Details for code_standards-9.129.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for code-standards 9.129.0
File Interpreter ABI Platform Actions
code_standards-9.129.0-py3-none-any.whl Python 3 none any Details for code_standards-9.129.0-py3-none-any.whl

Total release size: 3.0 MB

Release files / code_standards-9.129.0.tar.gz

Download URL code_standards-9.129.0.tar.gz
Size 1.5 MB
Tags Source
SHA-256 checksum
How to use checksums
100a19707529fedb64b77f5313752e40af0ab95f5e322066fc333a97659fb098
BLAKE2b-256 checksum
How to use checksums
5c8b5fb7fd657c0aa5e839a63d90ae7b7c4e2310c36212c69f193da02544019d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / code_standards-9.129.0-py3-none-any.whl

Download URL code_standards-9.129.0-py3-none-any.whl
Size 1.6 MB
Tags Python 3
SHA-256 checksum
How to use checksums
a26fe6bd7c094360f9ab1bb80af102ca361f06efdc4a770eec6708be0f235704
BLAKE2b-256 checksum
How to use checksums
7b0f86ebe5364e65ddceee0aa3a361481a3ff89c85addd3d34c9a5dc3f9c43bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for code-standards 9.129.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for code_standards-9.129.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

9.129.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page