Get your agent secured in 60 seconds. Three steps, no security expertise required.
pip install agentsec
# Pick your tier: basic, standard, strict, regulated agentsec init --tier standard --name my-agent
This creates AGENTSECURITY.md in your project root with sensible defaults.
# Edit AGENTSECURITY.md to match your agent's actual tools # Validate the policy agentsec validate . # Scan your codebase for violations agentsec check .
name: AgentSecurity Check
on: [pull_request]
jobs:
agentsec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install agentsec
run: pip install agentsec
- name: Validate policy
run: agentsec validate .
- name: Check codebase
run: agentsec check . --fail-on high
- name: Generate report
run: agentsec report . --format json -o agentsec-report.json
- uses: actions/upload-artifact@v4
with:
name: agentsec-report
path: agentsec-report.json
# .pre-commit-config.yaml
repos:
- repo: local
hooks:
- id: agentsec-validate
name: Validate AGENTSECURITY.md
entry: agentsec validate .
language: system
pass_filenames: false
Use agentsec to-prompt to generate an XML snippet for your agent's system prompt:
agentsec to-prompt .
Output (~50-100 tokens):
<agent_security_policy> <name>my-agent</name> <tier>standard</tier> <enforcement>warn</enforcement> <description>Processes support tickets</description> <location>./AGENTSECURITY.md</location> </agent_security_policy>
Add the security policy as system context when initializing your agent:
from agentsec.parser import parse_policy
policy = parse_policy(".")
system_context = f"""
You are operating under security tier: {policy.security_tier}
Enforcement mode: {policy.enforcement}
Declared tools: {', '.join(policy.declared_tool_names)}
"""
Place AGENTSECURITY.md in your project root alongside CLAUDE.md.
Claude Code will discover it automatically when configured.
# Validate AGENTSECURITY.md against the spec agentsec validate [path] # Scan codebase for violations agentsec check [path] --fail-on high|medium|low # Generate security scorecard agentsec report [path] --format text|json|badge # Initialize from template agentsec init --tier basic|standard|strict|regulated # Output policy properties as JSON agentsec read-properties [path] # Generate system prompt XML agentsec to-prompt [path]
[](https://agentsecurity.dev)
Replace standard with your tier. Color options:
basic — bluestandard — greenstrict — yellowregulated — redPre-built templates are available in the repository: