๐ก๏ธ CodeGuard CLI
A command-line tool to easily set up CodeGuard security rules for your AI coding assistants (Cursor, Claude, VSCode with Copilot).
๐ Table of Contents
โจ Features
- ๐ Quick Setup - Set up CodeGuard security rules in seconds
- ๐ฏ Multi-Platform Support - Works with Cursor, Claude, and VSCode with Copilot
- ๐ Secure by Default - Built with security best practices
- ๐ฆ Zero Configuration - No config files needed
- ๐ก๏ธ Path Traversal Protection - Secure file operations
- ๐ Smart File Handling - Automatically creates copies if files already exist
๐ฆ Installation
Global Installation (Recommended)
npm install -g @healerlab/codeguard-cli
Local Installation
npm install @healerlab/codeguard-cli
Using npx (No Installation Required)
npx @healerlab/codeguard-cli
๐ Usage
Basic Usage
Navigate to your project directory:
cd /path/to/your/project
Run the CLI:
codeguard-cli
Or if installed locally:
npx codeguard-cli
Select your AI assistant:
- Cursor - Sets up rules in
.cursor/ directory
- Claude - Sets up rules in
.claude/ directory
- VSCode with Copilot - Sets up rules in
.github/ directory
Done! CodeGuard rules are now set up in your project.
Example
$ cd my-awesome-project
$ codeguard-cli
Welcome to CodeGuard CLI Setup!
? Which AI Assistant do you want to setup CodeGuard for? (Use arrow keys)
โฏ Cursor
Claude
VSCode with Copilot
Setting up rules for Cursor...
Created codeguard-backend.mdc
Created codeguard-core.mdc
Created codeguard-frontend.mdc
Created codeguard-devops.mdc
Created codeguard-mobile.mdc
Created codeguard-embedded.mdc
Created codeguard-frameworks.mdc
Created codeguard-commands.mdc
Created guard-audit.md
Created guard-fix.md
Created guard-test.md
Setup completed successfully! ๐
๐ก๏ธ What is CodeGuard?
CodeGuard is a comprehensive security framework that helps AI coding assistants generate secure code by default. It includes:
Security Protocols
- Backend Security - SQL Injection prevention, IDOR protection, authentication best practices, SSRF prevention
- Frontend Security - XSS prevention, CSP headers, secure storage, clickjacking protection
- Mobile Security - Secure storage (Keychain/Keystore), SSL pinning, biometric authentication, OWASP MASVS compliance
- DevOps Security - Container security, Kubernetes hardening, CI/CD security, supply chain protection
- Core Security - Secrets detection, PII protection, cryptography standards, logging best practices
- Embedded/C/C++ Security - Buffer overflow prevention, unsafe function replacement, compiler hardening flags
- Framework Security - Django, Rails, Laravel, Node.js, .NET, Java specific security rules
Security Rule Files
| File |
Description |
Coverage |
codeguard-backend.mdc |
Backend security protocols |
SQL Injection, IDOR, SSRF, Authentication, Deserialization |
codeguard-core.mdc |
Core security fundamentals |
Secrets detection, PII protection, Cryptography standards |
codeguard-frontend.mdc |
Frontend security |
XSS prevention, CSP, Secure storage, Clickjacking |
codeguard-devops.mdc |
DevOps & Infrastructure |
Docker security, Kubernetes, CI/CD, Supply chain |
codeguard-mobile.mdc |
Mobile app security |
iOS Keychain, Android Keystore, SSL Pinning, OWASP MASVS |
codeguard-embedded.mdc |
Embedded/C/C++ security |
Buffer overflow prevention, Unsafe functions, Compiler flags |
codeguard-frameworks.mdc |
Framework-specific rules |
Django, Rails, Laravel, Node.js, .NET, Java |
codeguard-commands.mdc |
Interactive commands guide |
/guard-audit, /guard-fix, /guard-test usage |
Interactive Commands
/guard-audit - Perform security audit on your code
/guard-fix - Auto-repair security vulnerabilities
/guard-test - Generate security penetration tests
๐ Security
This CLI tool is built with security best practices:
- โ
Path Traversal Protection - All file operations validate paths
- โ
Input Validation - Directory and file paths are validated before operations
- โ
Error Handling - Secure error messages prevent information disclosure
- โ
Permission Checks - Validates write permissions before file operations
Security Features
- Path resolution and validation
- Directory existence and permission checks
- Secure file copying with path traversal prevention
- Environment-based error logging
๐ Requirements
- Node.js >= 14.0.0
- npm >= 6.0.0
๐ง Troubleshooting
Permission Denied Error
If you encounter permission errors:
# Check directory permissions
ls -la /path/to/your/project
# Ensure you have write permissions
chmod u+w /path/to/your/project
File Already Exists
If configuration files already exist, the CLI will automatically create copies with _COPY suffix:
File existing. Created copy codeguard-backend_COPY.mdc
Installation Issues
If you have issues installing globally:
# Use sudo on Linux/Mac (if needed)
sudo npm install -g @healerlab/codeguard-cli
# Or install locally
npm install @healerlab/codeguard-cli
Node.js Version
Ensure you're using Node.js 14 or higher:
node --version # Should be >= 14.0.0
๐ Project Structure
After running the CLI, your project will have:
your-project/
โโโ .cursor/ # For Cursor AI
โ โโโ rules/
โ โ โโโ codeguard-backend.mdc # Backend security (SQLi, IDOR, Auth)
โ โ โโโ codeguard-core.mdc # Core security (Secrets, PII, Crypto)
โ โ โโโ codeguard-frontend.mdc # Frontend security (XSS, CSP)
โ โ โโโ codeguard-devops.mdc # DevOps security (Docker, K8s, CI/CD)
โ โ โโโ codeguard-mobile.mdc # Mobile security (iOS, Android)
โ โ โโโ codeguard-embedded.mdc # Embedded/C/C++ security
โ โ โโโ codeguard-frameworks.mdc # Framework-specific security
โ โ โโโ codeguard-commands.mdc # Interactive commands documentation
โ โโโ commands/
โ โโโ guard-audit.md # Security audit command
โ โโโ guard-fix.md # Auto-fix vulnerabilities command
โ โโโ guard-test.md # Security testing command
โโโ .claude/ # For Claude AI
โ โโโ CLAUDE.md # Claude-specific instructions
โ โโโ rules/
โ โโโ codeguard-backend.mdc
โ โโโ codeguard-core.mdc
โ โโโ codeguard-frontend.mdc
โ โโโ codeguard-devops.mdc
โ โโโ codeguard-mobile.mdc
โ โโโ codeguard-embedded.mdc
โ โโโ codeguard-frameworks.mdc
โ โโโ codeguard-commands.mdc
โโโ .github/ # For VSCode with Copilot
โโโ copilot-instructions.md # Copilot-specific instructions
โโโ rules/
โโโ codeguard-backend.md
โโโ codeguard-core.md
โโโ codeguard-frontend.md
โโโ codeguard-devops.md
โโโ codeguard-mobile.md
โโโ codeguard-embedded.md
โโโ codeguard-frameworks.md
โโโ codeguard-commands.md
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature)
- Commit your changes (
git commit -m 'Add some AmazingFeature')
- Push to the branch (
git push origin feature/AmazingFeature)
- Open a Pull Request
๐ License
This project is licensed under the ISC License.
๐ Acknowledgments
- Built with security best practices
- Inspired by OWASP Top 10 and security frameworks
- Designed for modern AI coding assistants
๐ Support
For issues, questions, or contributions, please open an issue on the GitHub repository.
Made with ๐ก๏ธ by Healer