@healerlab/codeguard-cli
v1.0.3
Published
CLI to setup CodeGuard rules
Downloads
336
Readme
🛡️ 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-cliLocal Installation
npm install @healerlab/codeguard-cliUsing npx (No Installation Required)
npx @healerlab/codeguard-cli🚀 Usage
Basic Usage
Navigate to your project directory:
cd /path/to/your/projectRun the CLI:
codeguard-cliOr if installed locally:
npx codeguard-cliSelect 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
- Cursor - Sets up rules in
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/projectFile Already Exists
If configuration files already exist, the CLI will automatically create copies with _COPY suffix:
File existing. Created copy codeguard-backend_COPY.mdcInstallation 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-cliNode.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
