AgentKit
DocsKitsCLI ReferenceDesktop App

policy

ak policy compile

Propose policy rules from the project's instruction files without changing what is enforced.

Use ak policy compile to read your project's instruction files and propose a rule for each sentence that matches a known form. Proposals go to .agentkit/policy-candidates.yaml, which the engine never evaluates. Nothing takes effect until you promote it with ak policy adopt.

Usage

ak policy compile [flags]

The command accepts no positional arguments. It replaces any previous proposals and never writes .agentkit/policy.yaml.

Command flags

FlagDefaultDescription
--dir <path>.Project directory holding .agentkit/policy.yaml.
--source <file>The document's sourcesInstruction file to read, relative to the project directory. Repeatable.

Without --source, the command reads the sources listed in the active policy document, or AGENTS.md and CLAUDE.md when there is none. A source file that does not exist is skipped. A source that points outside the project is refused.

Shared flags are described in CLI conventions.

Common examples

ak policy compile
ak policy compile --source CLAUDE.md --json

Recognised sentence forms

The compiler understands a closed set of forms. A leading list marker is ignored, and paths may be wrapped in backticks or quotes.

Instruction formProposed ruleAction
Never edit <path> (also do not/don't, and modify, change, write to)protected_pathwarn
<path> is read-onlyprotected_pathwarn
Use <program>, never <other> (also not, instead of)command rewriting <other> to <program>rewrite
Never run <program> (also do not/don't)commandwarn
Run <check> after changing <path> (also editing, touching)required_checkwarn
After changing <path>, run <check>required_checkwarn
Do not run <check> for docs changesdiff_classwarn

A path must look like a path, so it needs a /, ., *, or ?. The diff-class form accepts docs, documentation, markdown, test, and tests (with an optional -only suffix) followed by changes or diffs.

A line that starts like an instruction (never, do not, don't, always, use, run, after, must, or avoid) but matches no form is reported as unrecognised and produces no proposal. Prose never compiles into a block.

Automation output

kind is policy.compile. The data payload contains:

FieldDescription
candidatesAbsolute path of the candidates file that was written.
sourcesInstruction files that were read.
candidates_foundProposals, each with id, rule, and quote (the instruction as written).
unrecognizedLines that read like rules but matched no form: file, line, and text.

Exit behavior

ExitMeaningWhat to do
0Proposals were written, including when no sentence matched a form.Review the proposals, then adopt the ones you want.
1An instruction file or the candidates file could not be read or written.Check the source paths and file permissions.
2Arguments were invalid.Correct the invocation.