policy checks and applies a policy proposal, a JSON file with the policy settings you want. policy check validates the proposal and prints the changes it would make. policy apply writes it after you confirm in a terminal, and only a person can run it.
policy subcommands and options
Which file policy writes
policy writes .cc-safety-net/policy.json in the project. With --global, it writes your user policy file instead.
Without --global, both subcommands refuse to run in the directory that holds your user .cc-safety-net/, because the user config directory is not a project. They print this error and exit 1:
policy diff report
Both subcommands print the same report beforeapply writes anything:
--global, the first line reads Scope: user (<path>). When nothing would change, the diff is the single line No changes. A side with no value reads (unset). check stops after the diff and exits 0.
What the project-scope diff compares
In project scope, the diff compares the effective policy before and after the change. The effective policy is your user policy merged with the project file, so the diff shows the level the session will run at, not the file’s own contents. A proposal that leaves outsafety.level restores the level inherited from the user policy. In user scope, the diff compares the user policy file itself and prints no Effective policy heading.
policy errors
An unknown option or subcommand, a missing file, or an extra argument prints an error to stderr and exits1 before any diff. Audit settings are user scope only, so a project proposal with an audit section also fails:
Applying a policy with policy apply
apply requires an interactive terminal on both stdin and stdout. Without one, it prints the command for you to run yourself, including --global when you passed it, and exits 1.
apply asks Apply this policy to <path>? [y/N] .
- Only
yoryes, in any case, confirms. A confirmed apply writes the file, printsPolicy applied: <path>, and exits0. - Any other answer, or end of input, declines. A declined apply prints
Cancelled; nothing was written.and exits0.
Agents cannot run policy apply
CC Safety Net blocks an agent that runspolicy apply, with the fixed id guard.policy-apply. policy check stays allowed, so an agent can draft a proposal and show you its diff. See Agent-run cc-safety-net policy apply.