Directives
Directives are comments that control encryption, typing, validation, and push targets. They sit on the line immediately above the key they apply to:
Directives must start with # — writing @directive without # is a parse error.
Available directives
File-level directives
These go at the top of the .sec file (or in dotsec.schema) and apply to the whole file:
Encryption directives
Type directives
Constraint directives
Metadata directives
Examples
Push target syntax
Push vs env injection
Since v6.0.0, @push=… values are considered owned by the push target and are excluded from:
dotsec runenv injectiondotsec exportplaintext output
This matches the typical pattern of pushing secrets to SSM / Secrets Manager for a runtime service to consume directly (e.g. a Lambda reading from SSM at startup), without also exposing them as local env vars.
If a value needs to be both pushed and injected locally — e.g. a DATABASE_URL you use during dotsec run -- npm dev and also push to staging SSM — add @also-env:
dotsec show always displays all entries regardless of @push / @also-env — it's an inspection tool, not an env-injection target.
v5 → v6 migration: in v5 every
@pushvalue was also injected. To preserve v5 behavior verbatim, add@also-envto every@push-tagged entry. To adopt v6 semantics, leave them as-is — local env shrinks to "things actually meant for local processes."
Schema files
When a project has multiple .sec files (dev, staging, production), per-key directives would be duplicated across all files. A schema file (dotsec.schema) solves this by extracting shared directives into one place.
Schema format
The schema uses the same directive syntax, but keys have no values:
How it works
With a schema in place:
- Schema file (
dotsec.schema) holds all per-key directives:@type,@push,@encrypt,@format,@pattern,@min/@max,@optional,@deprecated, etc. .secfiles hold only file-level directives (@provider,@key-id,@region) and key=value pairsdotsec validatechecks.secentries against the schema: missing keys, extra keys, type mismatches, constraint violationsdotsec setautomatically writes new key directives to the schema (not inline in.sec)- Inline per-key directives in
.secfiles are an error when a schema exists — usedotsec remove-directivesto clean them up
Directive classification
Discovery
The schema file is found automatically:
--schemaCLI flagDOTSEC_SCHEMAenvironment variabledotsec.schemain the same directory as the.secfile
Creating a schema
Run dotsec extract-schema on an existing .sec file to extract per-key directives into dotsec.schema:
See extract-schema command for details.
Choosing between inline and schema
Use inline directives when you have a single environment or a small project. Everything lives in one .sec file — nothing extra to manage.
Use a schema file when you have multiple environments, collaborate with a team, or want to generate typed code. A shared dotsec.schema keeps directive definitions in one place and prevents drift.
Migration path: start with inline directives, then run dotsec extract-schema when you're ready. This moves per-key directives to dotsec.schema and strips them from your .sec file.
Variable interpolation
${VAR} references are resolved at runtime by dotsec run. Single-quoted values are not interpolated (bash convention).
Configuration
All file-level configuration lives in the .sec file as directives — no external config file needed:
Use --sec-file to specify a different .sec file: