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
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: