Create AepCaw Policy
Overview
Create new AepCaw security policies from built-in templates, customized to the user's use case. Produces valid YAML policy files with correct structure, evaluation semantics, and defensive defaults for file, network, command, HTTP service, and Postgres-family database controls.
When to Use
- User asks to create/make/generate a new policy
- User describes a use case that needs a policy ("policy for my CI pipeline")
- User wants to set up AepCaw for the first time
- User wants controlled access to a declared HTTP API or Postgres-family database
- NOT for editing existing policies (use aep-caw-policy-edit)
Flow
Locate policy directory
- Look for
config.yml or config.yaml in the project root to find policies.dir
- If not found, look for a
configs/policies/ directory
- Fall back to asking the user with AskUserQuestion
Understand the use case
Use AskUserQuestion to ask: "What will this policy protect?"
| Use Case |
Template |
| AI agent (code tasks) |
default or agent-default |
| CI/CD pipeline |
ci-strict |
| Local development |
dev-safe |
| Strict agent sandbox |
agent-sandbox |
| Observation/profiling |
agent-observe |
| Declared HTTP API gateway |
Start from default |
| Postgres-family database access |
Start from default |
| Custom / other |
Start from default |
Select template
- Read the matching template from the policy directory (e.g.,
configs/policies/default.yaml)
- On Windows, prefer the
-windows variant if available (e.g., default-windows.yaml, ci-strict-windows.yaml)
- If templates are not available locally, use the schema reference to generate a baseline
Customize
Based on the template read in Step 3, ask only about gaps - skip categories the template already handles well:
- "Which domains does your app need to reach?" → add network rules
- "Any paths outside the workspace it needs?" → add file rules
- "Any commands to block or require approval?" → add command rules
- "Should any HTTP APIs be exposed through AepCaw?" → add
http_services plus providers when credential substitution is needed
- "Should any Postgres-family databases be mediated?" → add
db_services, database_connection_rules, database_rules, and policies.db
For database policies, ask for:
- service name, dialect (
postgres, aurora_postgres, redshift, cockroachdb), upstream host:port, and tls_mode
- connection constraints: DB user, database name, application name, replication/cancel handling
- statement intent: read/write/admin operations, schemas/objects, catalog selectors (
relations, functions) if known
- redaction preference:
policies.db.log_statements, approval_statement_preview, and approval_statement_preview_chars
- unavoidability posture:
off, observe, or enforce
Name & write
- Ask for a policy name
- Generate the YAML with descriptive section comments matching built-in policy style
- Write to the policy directory
Validate
Run: aep-caw policy validate <name>
If validation fails, fix and re-validate.
If aep-caw binary is not available, warn the user to validate manually.
Update config reminder
If config.yml has a policies.allowed list, remind the user to add the new policy name.
Guardrails
- Always use
version: 1
- Every policy must have
name and description
- End rule-list categories (file_rules, network_rules, command_rules) with a default-deny catch-all
- Use descriptive rule names in
verb-noun format (e.g., allow-npm, deny-ssh-keys)
- Include section comment headers matching built-in policy style
- Most specific selector wins. Exact paths beat catch-all globs regardless of listing order.
- Do not invent runtime support for non-Postgres databases. Current DB enforcement is Postgres-family only.
- For
http_services, prefer path/method rules over broad network allows when the user needs audited API surface control.
- For
database_rules, remember DB evaluation is not simple first-match-wins: any matching deny wins, non-deny rules must cover every object slot, and uncovered objects fail closed.
- For Postgres
UPDATE/DELETE access to sensitive relations, ask whether accidental full-table mutation should be blocked. Use require_where: true only on rules whose operations expand exclusively to modify and/or delete; explain that it is syntactic, WHERE true still satisfies it, and another unguarded non-deny rule can still cover the same effect.
- For DB
redirect, only author safe read-only Postgres relation replacement: one canonical source in relations, match_object_resolution: catalog_resolved, and redirect.relation.
Schema Reference
Read skills/aep-caw-policy-shared/schema-reference.md for the complete policy YAML schema before generating any policy content. If this file is not accessible, proceed using only the guardrails above plus the template file read in Step 3. Do not generate policy YAML without either the schema reference or a template.
1---2name: aep-caw-policy-create3description: Use when creating a new AepCaw security policy, including agent sandboxes, CI pipelines, development environments, HTTP service gateways, or Postgres-family database access policies4---56# Create AepCaw Policy78## Overview910Create new AepCaw security policies from built-in templates, customized to the user's use case. Produces valid YAML policy files with correct structure, evaluation semantics, and defensive defaults for file, network, command, HTTP service, and Postgres-family database controls.1112## When to Use1314- User asks to create/make/generate a new policy15- User describes a use case that needs a policy ("policy for my CI pipeline")16- User wants to set up AepCaw for the first time17- User wants controlled access to a declared HTTP API or Postgres-family database18- NOT for editing existing policies (use aep-caw-policy-edit)1920## Flow21221. **Locate policy directory**23 - Look for `config.yml` or `config.yaml` in the project root to find `policies.dir`24 - If not found, look for a `configs/policies/` directory25 - Fall back to asking the user with AskUserQuestion26272. **Understand the use case**28 Use AskUserQuestion to ask: "What will this policy protect?"2930 | Use Case | Template |31 |----------|----------|32 | AI agent (code tasks) | `default` or `agent-default` |33 | CI/CD pipeline | `ci-strict` |34 | Local development | `dev-safe` |35 | Strict agent sandbox | `agent-sandbox` |36 | Observation/profiling | `agent-observe` |37 | Declared HTTP API gateway | Start from `default` |38 | Postgres-family database access | Start from `default` |39 | Custom / other | Start from `default` |40413. **Select template**42 - Read the matching template from the policy directory (e.g., `configs/policies/default.yaml`)43 - On Windows, prefer the `-windows` variant if available (e.g., `default-windows.yaml`, `ci-strict-windows.yaml`)44 - If templates are not available locally, use the schema reference to generate a baseline45464. **Customize**47 Based on the template read in Step 3, ask only about gaps - skip categories the template already handles well:48 - "Which domains does your app need to reach?" → add network rules49 - "Any paths outside the workspace it needs?" → add file rules50 - "Any commands to block or require approval?" → add command rules51 - "Should any HTTP APIs be exposed through AepCaw?" → add `http_services` plus `providers` when credential substitution is needed52 - "Should any Postgres-family databases be mediated?" → add `db_services`, `database_connection_rules`, `database_rules`, and `policies.db`5354 For database policies, ask for:55 - service name, dialect (`postgres`, `aurora_postgres`, `redshift`, `cockroachdb`), upstream `host:port`, and `tls_mode`56 - connection constraints: DB user, database name, application name, replication/cancel handling57 - statement intent: read/write/admin operations, schemas/objects, catalog selectors (`relations`, `functions`) if known58 - redaction preference: `policies.db.log_statements`, `approval_statement_preview`, and `approval_statement_preview_chars`59 - unavoidability posture: `off`, `observe`, or `enforce`60615. **Name & write**62 - Ask for a policy name63 - Generate the YAML with descriptive section comments matching built-in policy style64 - Write to the policy directory65666. **Validate**67 Run: `aep-caw policy validate <name>`68 If validation fails, fix and re-validate.69 If `aep-caw` binary is not available, warn the user to validate manually.70717. **Update config reminder**72 If `config.yml` has a `policies.allowed` list, remind the user to add the new policy name.7374## Guardrails7576- Always use `version: 1`77- Every policy must have `name` and `description`78- End rule-list categories (file_rules, network_rules, command_rules) with a default-deny catch-all79- Use descriptive rule names in `verb-noun` format (e.g., `allow-npm`, `deny-ssh-keys`)80- Include section comment headers matching built-in policy style81- Most specific selector wins. Exact paths beat catch-all globs regardless of listing order.82- Do not invent runtime support for non-Postgres databases. Current DB enforcement is Postgres-family only.83- For `http_services`, prefer path/method rules over broad network allows when the user needs audited API surface control.84- For `database_rules`, remember DB evaluation is not simple first-match-wins: any matching deny wins, non-deny rules must cover every object slot, and uncovered objects fail closed.85- For Postgres `UPDATE`/`DELETE` access to sensitive relations, ask whether accidental full-table mutation should be blocked. Use `require_where: true` only on rules whose `operations` expand exclusively to `modify` and/or `delete`; explain that it is syntactic, `WHERE true` still satisfies it, and another unguarded non-deny rule can still cover the same effect.86- For DB `redirect`, only author safe read-only Postgres relation replacement: one canonical source in `relations`, `match_object_resolution: catalog_resolved`, and `redirect.relation`.8788## Schema Reference8990Read `skills/aep-caw-policy-shared/schema-reference.md` for the complete policy YAML schema before generating any policy content. If this file is not accessible, proceed using only the guardrails above plus the template file read in Step 3. Do not generate policy YAML without either the schema reference or a template.