Cupcake is a native policy enforcement layer for AI coding agents, built on OPA/Rego. It ensures AI agents follow predefined rules and security policies. Useful for operations teams managing AI agents in development and production environments. Integrates with Claude, Cursor, and Factory AI.
git clone https://github.com/eqtylab/cupcake.gitCupcake is a native policy enforcement layer for AI coding agents, built on OPA/Rego. It ensures AI agents follow predefined rules and security policies. Useful for operations teams managing AI agents in development and production environments. Integrates with Claude, Cursor, and Factory AI.
1. **Define Policies:** Start by writing Rego policies in Cupcake’s policy library. For example, create a file named `secrets.rego` with rules like `deny[msg] { input.api_key }` to block hardcoded secrets. Use the [Cupcake Policy Generator](https://cupcake.dev/policy-generator) for templates. 2. **Integrate with Your AI Agent:** Configure your AI coding tool (e.g., Cursor, Claude, or Factory AI) to route all code generation requests through Cupcake. For Cursor, add the Cupcake extension from the marketplace. For Claude, use the Cupcake API endpoint in your custom instructions. 3. **Test Policies Locally:** Run `cupcake test --policy secrets.rego --code generated.py` to validate policies against sample code. Iterate until all violations are resolved. 4. **Enforce in CI/CD:** Add Cupcake to your GitHub Actions or GitLab CI pipeline. Example workflow: ```yaml - name: Enforce Security Policies run: cupcake enforce --policy-dir ./policies --source-dir ./src ``` 5. **Monitor and Iterate:** Use Cupcake’s dashboard to track policy violations and agent compliance. Set up alerts for repeated failures to identify areas for improvement in your prompts or policies.
No install command available. Check the GitHub repository for manual installation instructions.
git clone https://github.com/eqtylab/cupcakeCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Enforce the following security policy on the AI coding agent's output: [POLICY_RULE]. Review the generated code for compliance and suggest fixes if violations are found. If the code is compliant, confirm its safety. Policy to enforce: [SPECIFIC_POLICY].
### Policy Enforcement Report
**Policy Rule:** *Do not use hardcoded secrets or API keys in the generated code. All sensitive data must be injected via environment variables or secure vaults.*
**Reviewed Code Snippet:**
```python
import os
# API Key for external service (VIOLATION: Hardcoded secret)
API_KEY = "sk_live_abc123xyz456"
def fetch_user_data(user_id):
response = requests.get(
f"https://api.example.com/users/{user_id}",
headers={"Authorization": f"Bearer {API_KEY}"}
)
return response.json()
```
**Compliance Status:** ❌ **FAILED**
**Violation Details:**
- Line 3: API key is hardcoded in the source code.
- Risk: Exposure of sensitive credentials in version control or logs.
**Suggested Fix:**
```python
import os
def fetch_user_data(user_id):
api_key = os.getenv("EXAMPLE_API_KEY") # Load from environment variable
if not api_key:
raise ValueError("API key not configured in environment variables.")
response = requests.get(
f"https://api.example.com/users/{user_id}",
headers={"Authorization": f"Bearer {api_key}"}
)
return response.json()
```
**Next Steps:**
1. Update the `.env` file in the project root:
```
EXAMPLE_API_KEY=sk_live_abc123xyz456
```
2. Add `.env` to `.gitignore` to prevent accidental commits.
3. Re-run the policy check to confirm compliance.
**Recommendation:** Integrate Cupcake into your CI/CD pipeline to automatically enforce this policy on every code generation request.Cloud ETL platform for non-technical data integration
IronCalc is a spreadsheet engine and ecosystem
Get more done every day with Microsoft Teams – powered by AI
Customer feedback management made simple
Enterprise workflow automation and service management platform
Automate your spreadsheet tasks with AI power
Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan