Generate and safely update agent-specific instruction files from one engineering policy
Project description
agent-policykit
One engineering policy in. Agent-specific instruction files out.
For teams using multiple AI coding agents in the same repository.
agent-policykit detects the stack in a repository, merges governance with language, framework, and project-type rules, and writes the exact instruction files each coding agent expects.
If your repo has Copilot, Cursor, Claude Code, Codex, Aider, or Gemini users,
agent-policykitkeeps them aligned on the same security, architecture, testing, and review guidance without hand-editing separate prompt files.
Why?
Most teams that adopt AI coding assistants hit the same problem quickly: every tool wants a different file, a different format, and a different maintenance path.
agent-policykit solves that with a compiler-style workflow:
| Situation | Without agent-policykit | With agent-policykit |
|---|---|---|
| Multiple agents in one repo | Prompt files drift and contradict each other | One shared policy generates all outputs |
| Stack-specific guidance | Generic prompts ignore framework and project type | Packs inject Python, FastAPI, monolith, SDK, and other stack context |
| Standards change | Manual edits across many files | diff and update regenerate safely |
| Security guidance changes | Accidental weakening or deletion is easy | Security downgrade blocking prevents silent removal |
Who it is for
- Engineering teams standardizing AI coding assistants across multiple repositories
- Platform and enablement teams managing secure defaults and review expectations
- Consultancies supporting different clients, stacks, and agent tools
- Open-source maintainers who want contributors using different agents to follow the same repo rules
Quickstart
Install from PyPI:
pip install agent-policykit
Or install the latest version directly from GitHub:
pip install "git+https://github.com/sidrat2612/agent-policykit.git"
CLI
Common CLI commands:
agent-policykit initdetects the stack and writes[tool.agent-policykit]intopyproject.toml.agent-policykit generatecompiles the merged policy bundle and writes all configured agent files.agent-policykit diffpreviews pending changes before regeneration.agent-policykit updaterefreshes existing generated files while preserving user-owned sections.agent-policykit validatechecks bundled packs for structural correctness.
Minimal flow:
agent-policykit init
agent-policykit generate
agent-policykit diff
agent-policykit update
Config File
Generated and manual workflows both use the same project config:
[tool.agent-policykit]
targets = ["copilot", "agents-md", "cursor", "claude-code"]
languages = ["python", "typescript"]
frameworks = ["fastapi", "nextjs"]
project_type = "api_service"
review_mode = false
Recommended config shape:
- Set
targetsto the agent files your repository actually needs. - Set
languages,frameworks, andproject_typeexplicitly when auto-detection is not enough. - Use
review_mode = trueor--mode reviewwhen you want stricter reviewer behavior in generated instructions.
What Gets Written
agent-policykit writes plain-text instruction files directly into the repository so they can be reviewed, diffed, and committed like any other source-controlled artifact.
Typical outputs include:
| Target | Output |
|---|---|
| GitHub Copilot | .github/copilot-instructions.md |
| GitHub Copilot path-scoped | .github/instructions/*.instructions.md |
| Portable AGENTS | AGENTS.md |
| Claude Code | CLAUDE.md plus .claude/rules/shared.md |
| Cursor | .cursor/rules/project.mdc |
| Aider | CONVENTIONS.md and .aider.conf.yml |
| Gemini CLI | GEMINI.md |
| Compatibility exports | AGENT_POLICY.<target>.md |
This is the core behavior: inspect repo context, compile one policy bundle, then write the file shape each agent actually consumes.
How It Works
agent-policykit is a policy compiler and safe updater. It does not replace your coding agent. It makes the instructions those agents read consistent and maintainable.
Execution flow:
- Detect languages, frameworks, project type, existing targets, and path-scoped instruction surfaces.
- Load governance, language, framework, and project-type YAML packs.
- Merge them into one
PolicyBundleusing priority rules. - Validate IDs, coverage, and structural integrity.
- Render target-native files through the adapter registry.
- Diff or update existing files using managed sections and downgrade protection.
What it does
- Detects repository context instead of forcing one generic prompt onto every project
- Compiles YAML rule packs into one merged policy bundle
- Renders native instruction files for Copilot, Claude Code, Cursor, Codex, Aider, Gemini CLI, and compatibility targets
- Generates path-scoped outputs for tools that support scoped instructions
- Preserves user-owned content outside managed sections during updates
- Blocks accidental security-rule removal unless
--forceis used - Condenses outputs automatically when target limits require it
What it does NOT do
- Does not call external LLM APIs
- Does not execute code from packs
- Does not replace the execution engine of Copilot, Claude Code, Cursor, Codex, or other agents
- Does not silently overwrite everything in existing instruction files
- Does not pretend every repo needs the same policy
How the workflow behaves in practice
agent-policykit initdetects the repository and writes project config intopyproject.toml.agent-policykit generatecompiles the merged policy bundle and writes the configured agent files.agent-policykit diffshows exactly what would change on regeneration.agent-policykit updaterefreshes managed sections while preserving user-owned content.
That means the tool behaves less like a prompt template and more like a code generator with safety checks.
Supported Agents
Tier 1 targets
| Agent | Output file(s) |
|---|---|
| GitHub Copilot (repo-wide) | .github/copilot-instructions.md |
| GitHub Copilot (path-scoped) | .github/instructions/*.instructions.md |
| AGENTS.md (portable) | AGENTS.md plus nested per-subproject files |
| Cursor | .cursor/rules/project.mdc |
| Claude Code | CLAUDE.md plus .claude/rules/shared.md and scoped rule imports |
| Aider | CONVENTIONS.md and .aider.conf.yml |
| OpenAI Codex | AGENTS.md (size-aware, up to 32 KiB) |
| Gemini CLI | GEMINI.md |
Tier 2 exported compatibility files
- Generic markdown fallback:
AGENT_POLICY.md - RooCode:
AGENT_POLICY.roocode.md - Windsurf:
AGENT_POLICY.windsurf.md - Zed:
AGENT_POLICY.zed.md - Warp:
AGENT_POLICY.warp.md - Junie:
AGENT_POLICY.junie.md - Devin:
AGENT_POLICY.devin.md - Amp:
AGENT_POLICY.amp.md - Augment Code:
AGENT_POLICY.augment-code.md - Factory:
AGENT_POLICY.factory.md - Jules:
AGENT_POLICY.jules.md - goose:
AGENT_POLICY.goose.md - opencode:
AGENT_POLICY.opencode.md - Phoenix:
AGENT_POLICY.phoenix.md - Semgrep:
AGENT_POLICY.semgrep.md - Ona:
AGENT_POLICY.ona.md
Safety Guarantees
- Security downgrade blocking: removing generated security rules requires
--force. - Managed-section ownership: user-written content outside managed blocks is preserved.
- Structured conflict notes: non-security rule removals are surfaced instead of disappearing silently.
- Size-aware rendering: outputs are condensed when targets have practical size limits.
- Dry-run support:
diffis non-destructive, andgenerateandupdatesupport--dry-run.
Pack Coverage
| Category | Count | Examples |
|---|---|---|
| Governance | 8 packs | architecture, base, compliance, operations, output contract, review, security, testing |
| Languages | 28 packs | Python, TypeScript, Java, Go, C#, Rust, Ruby, PHP, Kotlin, Swift, and more |
| Frameworks | 13 packs | FastAPI, Django, Flask, Express, NestJS, Next.js, Spring Boot, Rails, and more |
| Project types | 9 packs | API service, web app, microservice, worker, CLI tool, SDK, monolith, and more |
CLI Reference
| Command | Description |
|---|---|
init |
Interactive setup that detects stack and writes config |
detect |
Print detected languages, frameworks, project type, and existing targets |
generate |
Full pipeline: detect, load, merge, render, and write |
update |
Regenerate and merge safely against existing files |
diff |
Show the unified diff of pending changes |
validate |
Validate all loaded packs for structural correctness |
Flags
--target <name>limits output to specific adapter targets and is repeatable.--mode reviewactivates the stricter reviewer overlay.--dry-runshows changes without writing files.--forceoverrides security-downgrade blocking.--verboseor-venables detailed detection output.
Review Mode
Generate reviewer-oriented instructions with:
agent-policykit generate --mode review
This tells downstream agents to act like strict reviewers: skeptical, technically demanding, and explicit about missing safeguards.
Documentation
- Architecture for system design, merge flow, and production guardrails
- Supported agents for output contracts per target
- Language packs for stack coverage details
- Framework packs for framework-specific rule coverage
- Project types for architecture-specific pack behavior
Examples
The repository ships real example fixtures that are used in tests. These are the best way to see how the workflow actually behaves.
FastAPI service
Fixture: examples/fastapi-service/
What it represents:
- Python
- FastAPI
- API service
Suggested command:
cd examples/fastapi-service
agent-policykit detect
agent-policykit generate \
--target copilot \
--target copilot-path \
--target agents-md \
--target generic-markdown \
--target claude-code \
--target cursor \
--target aider \
--target gemini-cli \
--dry-run
Validated outputs:
.github/copilot-instructions.md.github/instructions/project.instructions.mdAGENTS.mdAGENT_POLICY.mdCLAUDE.md.cursor/rules/project.mdcCONVENTIONS.md.aider.conf.ymlGEMINI.md
Next.js app
Fixture: examples/nextjs-app/
What it represents:
- TypeScript
- Next.js
- Web app
Suggested command:
cd examples/nextjs-app
agent-policykit detect
agent-policykit generate \
--target copilot \
--target copilot-path \
--target agents-md \
--target generic-markdown \
--target cursor \
--target claude-code \
--target gemini-cli \
--dry-run
Validated outputs:
.github/copilot-instructions.md.github/instructions/project.instructions.mdAGENTS.mdAGENT_POLICY.md.cursor/rules/project.mdcCLAUDE.mdGEMINI.md
Rails monolith
Fixture: examples/rails-monolith/
What it represents:
- Ruby
- Rails
- Monolith
Suggested command:
cd examples/rails-monolith
agent-policykit detect
agent-policykit generate \
--target copilot \
--target copilot-path \
--target agents-md \
--target generic-markdown \
--target claude-code \
--target cursor \
--dry-run
Validated outputs:
.github/copilot-instructions.md.github/instructions/app.instructions.mdAGENTS.mdAGENT_POLICY.mdCLAUDE.md.cursor/rules/project.mdc
What these examples show
- Detection changes based on repo context instead of using one fixed prompt.
- Output targets can differ by stack and by target selection.
- Path-scoped instruction files are generated when the repo structure supports them.
- The same policy model produces different file formats without duplicating the source policy.
Contributing
Contributions are welcome. See CONTRIBUTING.md for guidelines.
Development setup:
- Clone the repository from
https://github.com/sidrat2612/agent-policykit.git. - Change into the
agent-policykitdirectory. - Create and activate a virtual environment with
python -m venv .venvandsource .venv/bin/activate. - Install dev dependencies with
pip install -e ".[dev]". - Run checks with
pytest,ruff check src/ tests/, andmypy src/agent_policykit --ignore-missing-imports.
Community
- Read CONTRIBUTING.md, CODE_OF_CONDUCT.md, SUPPORT.md, and SECURITY.md.
- Use public GitHub issues and pull requests for bugs, proposals, and design discussion.
- Keep private reporting for security and conduct matters only.
- These community docs follow guidance from Open Source Guides.
License
MIT — use it anywhere.
Built for teams that want one policy across many coding agents.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_policykit-0.1.0.tar.gz.
File metadata
- Download URL: agent_policykit-0.1.0.tar.gz
- Upload date:
- Size: 251.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc2ca67ce3f01f5eb5ea3d8ccd24e9aa451b5b0c421de1709fd271a5dc633391
|
|
| MD5 |
d5e3da20c64c6a6b4eb9a494adf8ef91
|
|
| BLAKE2b-256 |
cd0ce672d49ed8416ac3b3811a83a9cc7d66764c0bb3b2fb51a1d758eb6a2acf
|
Provenance
The following attestation bundles were made for agent_policykit-0.1.0.tar.gz:
Publisher:
workflow.yml on sidrat2612/agent-policykit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_policykit-0.1.0.tar.gz -
Subject digest:
cc2ca67ce3f01f5eb5ea3d8ccd24e9aa451b5b0c421de1709fd271a5dc633391 - Sigstore transparency entry: 1583911912
- Sigstore integration time:
-
Permalink:
sidrat2612/agent-policykit@bb64d4dfe143d560d59558ef24c39be60a9f7258 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sidrat2612
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@bb64d4dfe143d560d59558ef24c39be60a9f7258 -
Trigger Event:
release
-
Statement type:
File details
Details for the file agent_policykit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: agent_policykit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 130.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2fd60e48be2361a395d5a2d536f97d9508114637adec551eee4ff9693a5bea0
|
|
| MD5 |
18e186f3f5205b0d7c9fb69801a88d59
|
|
| BLAKE2b-256 |
e5d9e29f3ee20e6826df935c8edfbe021e05f0cb6515f287739683fc2c5dc24f
|
Provenance
The following attestation bundles were made for agent_policykit-0.1.0-py3-none-any.whl:
Publisher:
workflow.yml on sidrat2612/agent-policykit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
agent_policykit-0.1.0-py3-none-any.whl -
Subject digest:
d2fd60e48be2361a395d5a2d536f97d9508114637adec551eee4ff9693a5bea0 - Sigstore transparency entry: 1583912259
- Sigstore integration time:
-
Permalink:
sidrat2612/agent-policykit@bb64d4dfe143d560d59558ef24c39be60a9f7258 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sidrat2612
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@bb64d4dfe143d560d59558ef24c39be60a9f7258 -
Trigger Event:
release
-
Statement type: