bwrb schema
Inspect and manage your vault’s schema definition.
Synopsis
Section titled “Synopsis”bwrb schema <subcommand>Subcommands
Section titled “Subcommands”| Subcommand | Description |
|---|---|
| types | Alias for schema list |
| fields | Alias for schema list <typePath> |
| list | List schema contents |
| validate | Validate schema structure |
| new | Create a type or field |
| discover | Report frontmatter field-usage facts (descriptive) |
| diff | Show pending schema changes |
| migrate | Apply schema changes to notes |
| history | Show migration history |
Quick Examples
Section titled “Quick Examples”# List all typesbwrb schema listbwrb schema types
# Show specific type detailsbwrb schema list type taskbwrb schema fields task
# Validate schema structurebwrb schema validate
# Create a simple type without promptsbwrb --non-interactive schema new type idea --directory Ideas \ --fields marker:text,published:boolean --output json
# Report frontmatter field-usage facts over a folder (descriptive)bwrb schema discover ./notes
# Preview migrationbwrb schema diff
# Apply migrationbwrb schema migrate --executeList schema contents including types, fields, and detailed type information.
When a type, field, or select option has a description,
schema list surfaces it — as a dim suffix in the overview tree, on its own line
in type <name> detail view, and as a description key in --output json. This
makes the schema self-documenting: agents and humans can run
bwrb schema list --output json to learn what each type and field is for instead
of relying on out-of-band notes.
Synopsis
Section titled “Synopsis”bwrb schema list [options]bwrb schema list [options] <typePath>bwrb schema list [options] -t|--type <typePath>bwrb schema list types [options]bwrb schema list fields [options]bwrb schema list type [options] <name>Subcommands
Section titled “Subcommands”| Subcommand | Description |
|---|---|
| (none) | Show full schema overview |
types | List type names only |
fields | List all fields across all types |
type <name> | Show details for a specific type |
<typePath> | Alias for type <typePath> (except reserved nouns) |
Options
Section titled “Options”| Option | Description |
|---|---|
--output <format> | Output format: text, json |
-t, --type <typePath> | Alias for type <typePath> |
Targeting Rules
Section titled “Targeting Rules”- Reserved nouns are deterministic subcommands:
types,fields,type - Use shorthand (
<typePath>or--type) for all other type paths - If mixed forms are provided (for example positional +
--type), the command errors with guidance
Field provenance
Section titled “Field provenance”schema list fields lists the resolved fields for every type, so each type
shows its own fields plus the fields it inherits from a parent and the fields it
composes from traits — matching what schema list type <name> reports. Every
field row carries an origin so you can tell where it came from:
origin | Meaning |
|---|---|
own | Declared directly on the type |
trait:<name> | Composed from the named trait |
inherited:<name> | Inherited from the named ancestor type |
In text output the origin is the leading token in the DETAILS column. In JSON
output (--output json) each entry in data.fields gains an origin string
alongside the existing type, field, and definition. A schema with no
inheritance or traits lists the same fields as before, each with origin: "own".
Examples
Section titled “Examples”# Show full schema overviewbwrb schema list
# List all type namesbwrb schema list types
# List all fields across typesbwrb schema list fields
# Show details for a specific typebwrb schema list type taskbwrb schema list type objective/milestone
# Equivalent aliases for type detailsbwrb schema list taskbwrb schema list --type taskbwrb schema list -t objective/milestone
# JSON output for scriptingbwrb schema list --output jsonbwrb schema list types --output jsonbwrb schema list fields --output jsonbwrb schema list type task --output jsonbwrb schema list -t task --output jsontypes alias
Section titled “types alias”schema types is a discovery-friendly alias for schema list.
Synopsis
Section titled “Synopsis”bwrb schema types [options]Options
Section titled “Options”| Option | Description |
|---|---|
--output <format> | Output format: text, json |
--verbose | Show all types with fields inline |
Examples
Section titled “Examples”bwrb schema typesbwrb schema types --verbosebwrb schema types --output jsonfields alias
Section titled “fields alias”schema fields <typePath> is a discovery-friendly alias for schema list <typePath>.
Use schema list fields when you want the all-fields overview across every type.
Synopsis
Section titled “Synopsis”bwrb schema fields <typePath> [options]Options
Section titled “Options”| Option | Description |
|---|---|
--output <format> | Output format: text, json |
Examples
Section titled “Examples”bwrb schema fields taskbwrb schema fields objective/milestone --output jsonvalidate
Section titled “validate”Validate your schema.json file for structural correctness.
Synopsis
Section titled “Synopsis”bwrb schema validate [options]Options
Section titled “Options”| Option | Description |
|---|---|
--output <format> | Output format: text, json |
Description
Section titled “Description”Validates the schema.json file against the expected structure:
- Required fields are present
- Field types are valid
- Select options are properly defined inline on their fields
- Type hierarchies are consistent
- Types missing
output_diremit a warning (computed directory included)
Warnings are printed to stderr in text mode. In JSON mode, warnings are included in data.warnings.
Examples
Section titled “Examples”# Validate schemabwrb schema validate
# JSON output for CIbwrb schema validate --output jsonExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Schema is valid |
1 | Validation errors found |
Create schema types and fields interactively or through the bounded non-interactive type surface.
bwrb schema new type [name] [options]bwrb schema new field [type] [name]schema new type accepts --directory, --inherits, --description,
--output, and comma-separated --fields name:type definitions. In global
--non-interactive mode, the type name and every required value must be
explicit. The shorthand intentionally supports only field shapes that are
complete from a type name alone. A select or other prompt-rich definition is
rejected promptly without creating a partial type and tells you to rerun
schema new field <type> <field> in a TTY.
# Safe headless creationbwrb --non-interactive schema new type idea --directory Ideas \ --fields marker:text,published:boolean --output json
# Prompt-rich fields belong in the interactive field editorbwrb schema new field idea statusdiscover
Section titled “discover”Report descriptive facts about the frontmatter across a folder of Markdown
notes. discover reports what is there — every field, how often it appears, the
value-types it holds, and which files diverge. It never passes or fails, never
prescribes, and is safe to run anytime, including on a messy folder that has no
schema yet.
It works on an arbitrary folder path, not only a managed vault, so you can point it at unmanaged Markdown during onboarding.
Descriptive vs. audit
Section titled “Descriptive vs. audit”discover is descriptive: it states facts and exits non-zero only for a real
error (such as an unreadable path), never for “non-conforming” data.
bwrb audit is prescriptive: it reports what is
wrong relative to the schema, with exit codes and --fix. Use discover to
understand a folder; use audit to enforce the schema.
Two roles
Section titled “Two roles”| Role | When | What it surfaces |
|---|---|---|
| Onboarding | Before a schema exists | Every field, its frequency, value-type consistency, and which files diverge — raw material for designing types. |
| Drift detection | After a schema exists | Additionally: fields used but not defined, fields defined but unused, and values diverging from declared select options. |
A schema is used automatically when a .bwrb/schema.json is found at or above the
scanned folder (or via --vault). When none is found, discover runs in the
onboarding role. Use --no-schema to force the onboarding view even when a schema
is present.
Synopsis
Section titled “Synopsis”bwrb schema discover [path] [options]path defaults to the current directory.
Options
Section titled “Options”| Option | Description |
|---|---|
--output <format> | Output format: text (default), json |
--no-schema | Skip drift detection; report raw field facts only |
Examples
Section titled “Examples”# Scan the current directorybwrb schema discover
# Scan an arbitrary folder (onboarding)bwrb schema discover ./notes
# Structured facts for scripting or agentsbwrb schema discover ./notes --output json
# Skip drift even if a schema is presentbwrb schema discover ./notes --no-schemaJSON output
Section titled “JSON output”--output json emits the standard { "success": true, "data": ... } envelope.
The data object has this shape:
{ "root": "/abs/path/scanned", "totalFiles": 4, "filesWithFrontmatter": 3, "unreadable": [], // { file, error } for skipped files AND nested unreadable subdirs (never fatal) "schemaPresent": true, // whether a schema was loaded for drift "fields": [ { "field": "status", "count": 3, // notes in which the field appears "frequency": 1, // count / filesWithFrontmatter (0..1) "types": [ // observed value-types, by descending count { "type": "string", "count": 3 } ], "mixedTypes": false, // true when >1 non-empty value-type "divergingFiles": [], // files whose type differs from the most common "defined": true, // schema role: declared by any type? "divergingOptions": [ // schema role: values outside declared options { "value": "wibble", "files": ["c.md"] } ] } ], "drift": { // present only when a schema was loaded "usedButUndefined": ["deadline"], "definedButUnused": ["rating"], "optionDivergences": [ { "field": "status", "values": [ { "value": "wibble", "files": ["c.md"] } ] } ] }}Value-types are coarse, frontmatter-shaped buckets: string, number,
boolean, date (an ISO-ish date string), list, object, and empty
(null / empty string / empty list).
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
0 | Report produced (including for non-conforming data) |
2 | Real error (for example, the path is missing or unreadable) |
A scanned root that exists but whose contents cannot be listed (for example
a directory with chmod 000) is a real error and exits 2 — it is never
reported as “0 files”. By contrast, an unreadable nested subdirectory found
mid-walk is recoverable: the rest of the tree is still scanned (exit 0) and the
locked subdirectory is surfaced in the unreadable list rather than silently
dropped.
Show changes to the schema since the last migration.
Synopsis
Section titled “Synopsis”bwrb schema diff [options]Options
Section titled “Options”| Option | Description |
|---|---|
-o, --output <format> | Output format: text, json |
Description
Section titled “Description”Compares the current schema.json against the last migration snapshot to show:
- New types added
- Types removed
- Fields added to types
- Fields removed from types
- Field definitions changed
- Select options changed
Examples
Section titled “Examples”# Show what changedbwrb schema diff
# JSON output for scriptingbwrb schema diff -o jsonWorkflow
Section titled “Workflow”- Make changes to
.bwrb/schema.json - Run
bwrb schema diffto preview changes - Run
bwrb schema migrateto apply changes to existing notes
migrate
Section titled “migrate”Apply schema changes to existing notes in your vault.
Synopsis
Section titled “Synopsis”bwrb schema migrate [options]Options
Section titled “Options”| Option | Description |
|---|---|
-x, --execute | Actually apply the migration (default is dry-run) |
-y, --yes | Accept execute confirmations |
--set-version <version> | Set the new schema version for execute mode (semver, e.g. 1.2.3) |
--no-backup | Skip backup creation (not recommended) |
--show-changes | Show per-note before/after changes in the dry-run preview |
--output <format> | Output format: text, json |
Description
Section titled “Description”Migrations update existing notes when the schema changes:
- Add new required fields with default values
- Remove deleted fields
- Rename fields
- Update select options
- Move files to new output directories
Safety
Section titled “Safety”- Dry-run by default: Shows what would change without modifying files
- Automatic backup: Creates a backup before applying changes
- Explicit headless execution: Non-interactive runs with note changes require
--set-version; non-deterministic changes also require--yes - Atomic operations: All changes succeed or none are applied
- Vault-wide typed-note discovery: A note remains a migration target when its frontmatter type is valid even if it has been moved outside the type’s configured output directory
- Required-field blockers: If a planned cleanup would clear a required field and no schema default provides a safe replacement, preview JSON reports
blocked/blockers; execute exits non-zero before writing notes, backups, snapshots, version, or history. Set an explicit valid value and retry rather than accepting an arbitrary replacement option.
Examples
Section titled “Examples”# Preview migration (dry-run)bwrb schema migrate
# Apply migration with backupbwrb schema migrate --execute
# Apply non-interactively with JSON outputbwrb schema migrate --execute --set-version 1.1.0 --output json
# Apply a non-deterministic migration non-interactivelybwrb schema migrate --execute --set-version 2.0.0 --yes --output json
# Apply without backup (not recommended)bwrb schema migrate --execute --no-backupWorkflow
Section titled “Workflow”- Make changes to
.bwrb/schema.json - Run
bwrb schema diffto preview changes - Run
bwrb schema migrateto preview note updates - Run
bwrb schema migrate --executeto apply
history
Section titled “history”View the history of schema migrations applied to your vault.
Synopsis
Section titled “Synopsis”bwrb schema history [options]Options
Section titled “Options”| Option | Description |
|---|---|
--limit <n> | Number of entries to show (default: 10) |
-o, --output <format> | Output format: text, json |
Description
Section titled “Description”Shows a log of all migrations that have been applied:
- Migration timestamp
- Changes included
- Files affected
Examples
Section titled “Examples”# Show migration historybwrb schema history
# Show last 5 migrationsbwrb schema history --limit 5
# JSON outputbwrb schema history -o jsonSee Also
Section titled “See Also”- Schema — Understanding schema structure
- Migrations — Migration workflow
- bwrb audit — Validate notes against schema