π‘οΈ A specialized cybersecurity agent for OpenCode that analyzes code for security vulnerabilities and provides clear explanations in plain English.
The Security Critic Agent helps developers identify and fix security vulnerabilities in their code. It provides:
- π Comprehensive Security Analysis - Detects common vulnerabilities like SQL injection, XSS, hardcoded secrets, and more
- π Plain English Explanations - Security issues explained without technical jargon
- π― Actionable Recommendations - Specific fix suggestions with code examples
- π¨ Severity Classification - Issues categorized as HIGH, MEDIUM, or LOW priority
- π Safe by Default - Read-only permissions prevent accidental code changes
This guide shows you how to add the Cybersecurity Critic Agent to your OpenCode installation.
-
Copy the agent file to your project:
mkdir -p .opencode/agent cp security-critic.md .opencode/agent/
-
Add to your project's AGENTS.md:
cp AGENTS.md ./
-
Start OpenCode in your project:
opencode
-
Use the agent:
@security-critic review my code for security issues
-
Create global agent directory:
mkdir -p ~/.config/opencode/agent -
Copy the agent globally:
cp security-critic.md ~/.config/opencode/agent/ -
Available in all OpenCode sessions
-
Add to your opencode.json:
cp opencode-security.json ./opencode.json
-
Or merge with existing configuration
@security-critic analyze the authentication system
@security-critic check login.py for security vulnerabilities
@security-critic review this Express.js API for injection attacks
@security-critic perform security audit of entire codebase
- SQL Injection
- Hardcoded Secrets (API keys, passwords)
- Path Traversal
- Dynamic Code Execution
- Command Injection
- Cross-Site Scripting (XSS)
- Weak Cryptography (MD5, SHA1)
- Insecure Random Generation
- Insecure Deserialization
- Information Disclosure
- Insufficient Logging
- Weak Password Policies
#!/bin/sh
# .git/hooks/pre-commit
opencode agent run security-critic --files=$(git diff --cached --name-only)
if [ $? -ne 0 ]; then
echo "Security issues found! Please review before committing."
exit 1
fi# .github/workflows/security.yml
name: Security Review
on: [push, pull_request]
jobs:
security:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Security Critic
run: |
opencode agent run security-critic --format json > security-report.json
- name: Upload Report
uses: actions/upload-artifact@v2
with:
name: security-report
path: security-report.jsonYou can specify different models in the agent configuration:
0.0-0.2: Very focused analysis (recommended for security)0.3-0.5: Balanced responses0.6-1.0: More creative exploration
The agent is configured with read-only permissions by default:
- β Read files
- β Search code
- β Fetch documentation
- β Edit files
- β Run commands
- β Write files
- Use Early and Often: Run security reviews during development, not just before deployment
- Combine with Human Review: Use the agent as a supplement to, not replacement for, code reviews
- Focus on HIGH Issues: Prioritize fixing HIGH severity issues first
- Learn from Recommendations: Use the explanations to improve your security knowledge
- Update Regularly: Keep the agent updated for the latest security patterns
# Check if agent file exists
ls .opencode/agent/security-critic.md
# Restart OpenCode
# Exit and restart opencode# Check file permissions
ls -la .opencode/agent/security-critic.md
# Fix permissions if needed
chmod 644 .opencode/agent/security-critic.md# Check available models
opencode models
# Update agent configuration with available modelTo improve the Security Critic Agent:
- Add New Patterns: Update the agent prompt with new vulnerability patterns
- Improve Explanations: Make security explanations clearer and more accessible
- Framework Support: Add framework-specific security patterns
- False Positive Reduction: Fine-tune patterns to reduce false positives
- Documentation: See SECURITY_USAGE.md for detailed examples
- Issues: Report bugs or request features on the OpenCode GitHub repository
- Community: Join the OpenCode Discord for community support
This repository contains:
- Security Critic Agent (
security-critic.md) - Main agent configuration - Installation Guide - Step-by-step setup instructions
- Usage Examples - Real-world examples and best practices
- JSON Configuration - Alternative configuration format
- Documentation - Comprehensive guides and references
Contributions are welcome! Here's how you can help:
- Add New Security Patterns - Update the agent with new vulnerability detection
- Improve Explanations - Make security advice clearer and more accessible
- Framework Support - Add patterns for specific frameworks
- Bug Reports - Report issues or false positives
- Documentation - Improve guides and examples
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.
π Happy secure coding! Use the Security Critic Agent to catch vulnerabilities early and build more secure applications.