Extend templates and config files using the extends field
mainYou can build upon existing templates or other configuration files using the extends field in your JSON configuration. This prevents duplication and allows for modular security policies.
Extending Templates
Use the name of a built-in template (e.g., "extends": "code").
Extending Files
Use a file path (e.g., "extends": "./shared/base-config.json"). The value is treated as a file path if it contains / or \, or starts with .. Relative paths are resolved relative to the config file's directory.
Merging Logic
When extending, settings are merged according to these rules:
- Slice fields (e.g.,
paths,commands): Values are appended and deduplicated. - Boolean fields: Uses OR logic (the field is
trueif either the base or the extension enables it). - Integer fields (e.g.,
ports): The extension value overrides the base value (use0in the extension to keep the base value).
Chains are supported (File A extends Template B, File C extends File A), but circular extensions are rejected.
{
"extends": "code",
"filesystem": {
"allowWrite": [ ".", "/tmp" ]
}
}