Skip to content

bear validate

Run the validation steps of every artifact and library against the working tree. No environment, no change detection by default, no plan, no deployment.

bear validate [artifacts...]
bear validate                       # Validate every artifact and library
bear validate user-api              # Validate a single artifact
bear validate user-api order-api    # Validate multiple artifacts
bear validate --environment int     # Inject ENVIRONMENT=int into the steps
bear validate --changed-since int   # Validate only what changed since int's last deploy
bear validate --concurrency 5       # Limit parallel validation jobs
bear validate -v                    # Stream step output while it runs
bear validate -d ./other-project    # Validate a different directory

Validate is the merge-request command in the chain doctor → validate → plan → apply. bear doctor reads the configuration, bear validate runs the configured build steps, bear plan <environment> produces the deployment a human reviews without running anything, and bear apply builds and deploys it. bear apply's build phase runs the exact same languages.<lang>.steps validate does, immediately before each deploying artifact's target steps — so validate is not a rehearsal for a second, different run; it is the same check, available earlier and for free of any environment or deployment context. Run it in the merge request for fast feedback, and rely on apply to run it again, for real, right before every deployment.

Arguments

Argument Description
[artifacts...] Optional artifact and library names; omit to validate everything discovered

Every positional argument is an artifact name. There is no environment argument: bear validate int fails with unknown artifact "int".

Without arguments, every discovered artifact and library in the current working tree is validated. Naming artifacts validates exactly those: dependencies are never added, so bear validate checkout-api does not also validate the shared library it depends on. A repeated name is validated once.

A name that matches nothing is an error, so a typo fails the job instead of quietly validating nothing:

Error: unknown artifact "chekout-api"

Several misses are reported together, sorted: unknown artifact "other", "typo". An unmatched name rejects the whole selection before the first step runs, so nothing is validated.

Selection ignores deployment policy entirely. An artifact with no environments allowlist can never be deployed anywhere and is still validated.

An allowlist is still checked for validity, though, because validate loads the whole artifact graph before it runs anything. An entry naming an environment the project does not declare is a configuration error, and it fails the run whatever you selected:

Error: error loading artifacts: artifact "web" allows undeclared environment "preprd"; bear.config.yml declares dev, int, prd

Flags

Flag Description
--environment <name> Optional; must be declared in bear.config.yml. Injects ENVIRONMENT into the validation steps
--changed-since <name> Optional; must be declared in bear.config.yml. Narrows the selection to artifacts (and their dependents) changed since that environment's last deployed commit in bear.lock.yml
--concurrency <n> Max parallel validation jobs (default: 10)
-d, --dir <path> Project directory (default: .)
-v, --verbose Stream subprocess output while retaining bounded failure diagnostics

--environment only names the variable handed to the steps, with the same precedence a plan's validation uses — language vars, then target vars, then artifact vars, then the selected environment — so a step behaves identically in a merge request and in a deployment. It selects no deployment policy, reads no history, and changes no verdict. It must still name an environment the project declares, so a typo cannot silently inject a value no deployment will ever use. Invalid values are rejected before the workspace is touched: with a project declaring dev, int, prd, --environment production fails with unknown environment "production": bear.config.yml declares dev, int, prd. Without the flag, steps inherit whatever ENVIRONMENT the CI job already exports; Bear injects nothing and does not treat an inherited value as a selection.

--changed-since <name> is a different environment than --environment: it names which row of bear.lock.yml gates the selection, not which value is injected into a step. It runs the same file-level comparison bear plan uses — the current working tree (including uncommitted changes) against that environment's last deployed commit per artifact, including dependency propagation — and drops every artifact (or library) that comparison finds unaffected. An artifact with no recorded history in that environment is always affected, the same "new artifact" case plan reports. Naming artifacts still selects exactly those names first (dependencies are never added); --changed-since only narrows that selection further, it never widens it. Unlike the rest of validate, this requires Git and reads bear.lock.yml; a project not yet under Git, or not yet holding any history for that environment, will either fail or (with no history at all) validate everything, exactly like a first bear plan would. It must name a declared environment, rejected the same way and at the same point as --environment. It never writes bear.lock.yml or .bear/plan.yml, and it selects no deployment policy: an artifact filtered out here is reported as skip (n): with reason no changes detected, in a summary block also naming Changed since: <name>, whether or not the run otherwise fails. A selection that changes nothing at all prints No changes detected since <name>'s last deploy. Nothing to validate. and exits 0, the same way an empty bear plan reports nothing to plan.

The deployment flags are not accepted: --pin, --no-commit, --git-remote, and --git-branch fail with unknown flag. The global -f, --force is accepted because it is a root flag, but it has nothing to override here and does nothing.

--concurrency defaults to 10, the same default as bear plan and bear apply. Lower it when steps contend for one shared resource — a Docker daemon, a test database, a rate-limited registry — or when interleaved job output is hard to read. It bounds only how many jobs run at once: a failing artifact does not stop the others, and every selected artifact is attempted.

What It Does Not Do

Validation has no deployment semantics:

  • No environment argument and no deployment policy. environments allowlists gate nothing here, no artifact is enabled or blocked, and nothing is approved. They are still checked against the project's declared environments, because that is a configuration error, not a policy decision.
  • No change detection, by default. Every selected artifact runs whether or not it changed. See Cost. Pass --changed-since <environment> to opt into scoping the selection to what changed; see Flags.
  • No deployment history, by default. bear.lock.yml is neither read nor written, unless --changed-since is given, in which case it is read — never written — to find each artifact's last deployed commit in that environment.
  • No plan. .bear/plan.yml is neither read, written, nor removed. A plan saved by an earlier bear plan survives a validate run untouched, so validating cannot invalidate an approval.
  • No deploy section, ever, and no skip section unless --changed-since filtered something. There is no Environment: fact block and no Run 'bear apply' hint, with or without --changed-since.
  • No Git, by default. Validate never shells out to Git unless --changed-since is given. Without it, validate works in a shallow clone, a single-commit CI checkout, or a plain export that is not a repository at all, and it cannot require clean source, because it never looks at source control. --changed-since requires a real Git repository and fails if one is not present.

It does take the nonblocking advisory workspace lock on .bear/workspace.lock, creating .bear/ if needed, because it reads a working tree that a concurrent plan or apply may be rewriting. Running it against a workspace another Bear process holds fails immediately rather than waiting:

Error: cannot lock workspace /src: cannot acquire lock /src/.bear/workspace.lock (another bear process may be running): resource temporarily unavailable

It takes no repository lock, because it runs no Git and publishes nothing. See History And State for what those two locks do and do not guarantee.

Cost

Validate deliberately does not scope work to the changed files by default. It validates everything, or exactly the artifacts you name. In a large monorepo that costs time on every pull request, and without --changed-since Bear offers exactly two levers: name the artifacts a job should cover, and tune --concurrency. --changed-since <environment> is the opt-in third lever: it scopes the run to what changed since that environment's last deployment, using bear.lock.yml, the same source bear plan uses — Bear still does not infer it from a base ref or CI metadata; you name the environment whose history should gate the run.

Output

Validate brands itself like plan and apply, reports each job while it runs, and closes with one sentence:

Bear Validate
─────────────

Validating 4 artifacts

  shared:             Validating...
  generator:          Validating...
  generator:          Validating... [no validation steps]
  generator:          Validation complete after 0s
  checkout-api:       Validating...
  checkout-api:       Validating... [1/2 Test]
  kira-teams-adapter: Validating...
  kira-teams-adapter: Validating... [1/2 Test]
  shared:             Validating... [1/2 Test]
  shared:             Validating... [2/2 Build]
  kira-teams-adapter: Validating... [2/2 Build]
  checkout-api:       Validating... [2/2 Build]
  shared:             Validation complete after 3s
  checkout-api:       Validation complete after 3s
  kira-teams-adapter: Validation complete after 3s

Validation complete: 4 artifacts in 3s

Progress uses the same reporting as plan and apply: without a terminal, one plain line per job on every status change, job names padded into a common column, a Still validating... line every 10 seconds per running job, and the remaining backlog appended to the last running job's heartbeat as (1 job queued). Interactive terminals draw an animated progress bar instead, and --verbose selects the plain display even on a terminal while streaming step output as <artifact> | <step> | <line>. See Live Output.

An artifact whose language defines no validation steps is reported as no validation steps and completes successfully. That keeps a silently unvalidated artifact visible without turning a deliberate configuration into a failure.

A failing run reopens the summary with the failures only, the way a failed apply reports:

  checkout-api:       Validation failed after 1s: Test: exit status 1
    FAIL Test/checkout-api: assertion failed
  shared:             Validation failed after 2s: Build: exit status 2
    FAIL Build/shared: compile error
  kira-teams-adapter: Validation complete after 4s

────────────────────────────────────────

failed (2):
  - checkout-api (services/checkout-api): Test: exit status 1
  - shared (libs/shared): Build: exit status 2

Validation failed: 2 passed, 2 failed in 4s

A successful run prints no rule and no summary block at all, so the block's presence is itself the signal. It carries no Environment: line, because validation selected none. Entries are one line each, - <name> (<path>): <reason>, with the failing step's error as the reason, sorted by name so two runs are comparable even though jobs finish in any order. The list indexes the log above it: the bounded output tail stays indented four spaces under the job line that reported the failure. Treat those tails as sensitive; capture is bounded, not redacted.

--changed-since is the one thing that still opens a summary block on an otherwise successful run: whatever it filtered out is listed under skip (n): with reason no changes detected, next to a Changed since: fact instead of Environment:. A run with nothing filtered prints neither the rule nor the fact, same as without the flag.

Exit Code

0 when every selected artifact passed, including artifacts with no validation steps, and including a --changed-since run that filtered out everything. 1 for any failing step, an unknown artifact name, an --environment or --changed-since the project does not declare, a missing bear.config.yml, a configuration or discovery error such as an undeclared allowlist entry, a workspace held by another Bear process, or — with --changed-since — a missing Git repository or an unreadable bear.lock.yml. A failing run also prints the joined step errors on stderr after the summary:

Error: validation failed: Build: exit status 2
Test: exit status 1

In CI

Run it in the merge/pull request job. Without --changed-since it needs no deployment credentials, no environment, and no Git history, and it must never be paired with bear apply in the same job. Adding --changed-since <environment> trades that Git-free guarantee for a smaller job: it still needs no deployment credentials, but it does need a real Git checkout (not necessarily deep, since the comparison is against one recorded commit, not a base branch) and read access to bear.lock.yml. See Merge Request Validation for GitHub Actions, GitLab CI, and Jenkins templates.