codeguard is a standalone Go service and CLI for repository checks around code quality, design boundaries, security, CI/CD hygiene, and AI prompt governance.
go install github.com/devr-tools/codeguard/cmd/codeguard@latestOr from this repository:
make buildcodeguard version reports the embedded module version for binaries installed
with go install module@version. Local source builds report
0.1.0-dev+<revision> (with a .dirty marker for modified worktrees) when Go
embeds VCS metadata.
Or in GitHub Actions from GitHub Marketplace:
- name: Devr Codeguard
uses: devr-tools/codeguard@v1.1.1For SDK consumers:
go get github.com/devr-tools/codeguard/pkg/codeguardcodeguard init
codeguard validate -config codeguard.yaml
codeguard doctor -config codeguard.yaml
codeguard scan -config codeguard.yaml
codeguard scan -config codeguard.yaml -folder ./service/api
codeguard scan -folder ./service/api -profile startup
codeguard waivers audit -config codeguard.yaml
codeguard rules
codeguard profiles
codeguard explain prompts.secret-interpolation
codeguard baseline -config codeguard.yaml -output codeguard-baseline.jsoncodeguard init writes codeguard.yaml by default.
Use codeguard scan -folder <path> when you want to scan only one folder. -path <path> is accepted as an alias. If no config file exists and you did not pass -config, folder scans use CodeGuard's built-in default config; add -profile startup, -profile strict, -profile enterprise, or -profile ai-safe to choose a default profile.
After upgrading CodeGuard, run codeguard waivers audit -config codeguard.yaml to identify waiver cleanup candidates. CodeGuard stores audit snapshots with version, config fingerprint, scan scope, and matched finding fingerprints; it only marks a waiver as stale after upgrade when prior comparable evidence shows the waiver matched findings before and matches none now. JSON output is available with -format json.
If you prefer a JSON example, start from examples/codeguard.json.
Use this sequence for a real repository:
codeguard initcodeguard validate -config codeguard.yamlcodeguard doctor -config codeguard.yamlcodeguard scan -mode diff -config codeguard.yamlcodeguard waivers audit -config codeguard.yamlafter CodeGuard upgradescodeguard baseline -config codeguard.yaml -output codeguard-baseline.jsonif the repo has pre-existing debt
After that, add a full scan in scheduled CI and tighten check families incrementally. The detailed rollout guidance lives in Production rollout.
failfindings are intended to block until fixed, waived, or baselined.warnfindings are advisory by default and are best used for gradual cleanup.codeguard ruleslists every rule with section, level, execution model, and language coverage.codeguard explain <rule-id>explains what a specific failed check means and how to fix it.
The public SDK import path is:
import "github.com/devr-tools/codeguard/pkg/codeguard"Minimal example:
package main
import (
"context"
"log"
"github.com/devr-tools/codeguard/pkg/codeguard"
)
func main() {
cfg := codeguard.ExampleConfig()
report, err := codeguard.Run(context.Background(), cfg)
if err != nil {
log.Fatal(err)
}
_ = report
}- Go-first runtime support
- Standalone reusable package layout
- Config, runner, report, and CLI boundaries separated
- Exclusions, waivers, and baselines for incremental rollout
- Custom rule packs for repo-specific regex, content, and path policies
- Policy profiles such as
startup,strict,enterprise, andai-safe - Cached file-hash scan results for faster repeat runs
doctorchecks for config, Git, govulncheck, targets, and cache setuptext,json,sarif, andgithubreport formats- Diff-mode filtering down to changed lines when Git history is available
- Production rollout tools such as baselines, waivers, diff scans, and rule metadata discovery
Language-specific engines can be added later without changing the repo shape.