Code Security Skill is a security knowledge base and MCP server for AI coding assistants. It gives supported assistants always-on secure-coding instructions and lets them retrieve feature-specific security guidance before writing or reviewing security-sensitive code.
It is a secure-development aid, not a vulnerability scanner. Use it together with threat modeling, code review, tests, SAST, DAST, dependency scanning, secret scanning, and expert security review.
Developer asks an AI assistant to build or review a feature
|
v
Always-on static security instructions are loaded
|
v
AI calls the MCP tool search_security when appropriate
|
v
MCP server searches the versioned CSV knowledge base
|
v
AI applies relevant checklists, vulnerability guidance, and rules
The project provides two complementary layers:
- Static rules: platform-specific instruction files that remind the AI to apply secure-development practices and query the knowledge base.
- MCP retrieval: a local stdio MCP server exposing
search_security(query, mode, lang)for topic-specific guidance.
The MCP server retrieves guidance. It does not automatically scan source code, prove that generated code is secure, or replace security testing tools.
src/code-security is the repository's single source of truth.
| Dataset | Coverage |
|---|---|
| Vulnerability profiles | 50 |
| Feature security checklists | 26 |
| Language, framework, and engineering rules | 51 |
| Cryptography guides | 12 |
| OWASP ASVS 5.0.0 chapter index | 17 chapters / 345 requirements |
| MITRE CWE Top 25 2025 | 25 ranked weaknesses |
| Extended CWE mappings | SSTI (CWE-1336) and NoSQL Injection (CWE-943) |
| Governed assurance controls | 15 |
The validation script verifies complete category coverage for:
- OWASP Web Application Top 10 2025
- OWASP API Security Top 10 2023
- OWASP Top 10 for LLM Applications 2025
- OWASP ASVS 5.0.0 chapter totals
- MITRE CWE Top 25 2025
The vulnerability profiles also include Server-Side Template Injection (SSTI), NoSQL Injection, supply-chain failures, cloud and container misconfiguration, API authorization failures, and LLM-specific risks.
| Tool | Static rules | MCP configuration |
|---|---|---|
| Claude Code | CLAUDE.md and local skill copy |
.mcp.json |
| Cursor | .cursor/rules/code-security.mdc |
.cursor/mcp.json |
| GitHub Copilot in VS Code | .github/copilot-instructions.md |
.vscode/mcp.json |
| Windsurf | .windsurf/rules/code-security.md |
.windsurf/mcp_config.json |
| OpenAI Codex | AGENTS.md |
.codex/config.toml |
| Antigravity | GEMINI.md |
~/.gemini/config/mcp_config.json |
The installer copies the shared MCP server and knowledge base to
~/.code-security-skill/. Platform configuration files then start that local
server with the Python interpreter used during installation.
Generated project files are intentionally not committed to this source repository.
- Python 3
- The Python
mcppackage for runtime MCP queries - Node.js 14 or later only when using the npm CLI
- Git only when installing directly from the repository
Install the MCP runtime dependency:
python -m pip install mcpOptional MIME type validation support:
python -m pip install python-magicOn systems where the interpreter command is python3, replace python with
python3 in the examples below. On Windows, py -3 may also be used.
Run installation commands from the root of the target project, not from this source repository. The installer intentionally refuses to install into the source repository to avoid generating duplicate knowledge-base copies.
After the codesecurity package is published or installed from a local
package, initialize the current project:
npm install -g codesecurity
cd /path/to/your-project
codesecurity initInstall only selected integrations:
codesecurity init --ai claude
codesecurity init --ai cursor copilot codex
codesecurity init --ai antigravityRefresh existing generated files and MCP entries:
codesecurity init --forcegit clone --depth 1 https://github.com/Chiehyii/code-security-skill.git
cd /path/to/your-project
python /path/to/code-security-skill/scripts/install_skill.py install .Install selected integrations:
python /path/to/code-security-skill/scripts/install_skill.py install . --ai claude
python /path/to/code-security-skill/scripts/install_skill.py install . --ai cursor copilot
python /path/to/code-security-skill/scripts/install_skill.py install . --forceValid --ai values are claude, cursor, copilot, windsurf, codex,
antigravity, and all. The default is all.
Using the npm CLI:
codesecurity uninstall
codesecurity uninstall --ai cursor copilot
codesecurity uninstall --global-serverUsing the Python installer:
python /path/to/code-security-skill/scripts/install_skill.py uninstall .
python /path/to/code-security-skill/scripts/install_skill.py uninstall . --ai codex
python /path/to/code-security-skill/scripts/install_skill.py uninstall . --global-server--global-server also removes the shared ~/.code-security-skill/ directory.
Do not use it while another project still relies on that shared MCP server.
After installation, restart or reload the AI tool so it discovers the new rules and MCP configuration. Then request normal development or review work:
Build a login system with secure session management.
Create an API endpoint for updating user profiles.
Review this file-upload handler for security issues.
Implement a password-reset flow.
Check this MongoDB query for NoSQL injection.
The static rules instruct the AI to call search_security before handling
security-sensitive features. A typical MCP request looks like:
{
"query": "login authentication session",
"mode": "all",
"lang": "python"
}Available modes:
| Mode | Result |
|---|---|
all |
Combined security report |
checklist |
Feature-specific implementation checklist |
vuln |
Vulnerability profiles and fix patterns |
rules |
Language-specific secure-coding rules |
crypto |
Cryptography recommendations |
asvs |
OWASP ASVS verification areas |
cwe |
CWE root causes |
control |
Assurance controls such as SAST, DAST, SBOM, and fuzzing |
The same search engine can be used without an MCP client:
# Combined report
python src/code-security/scripts/search.py "login authentication" --lang python
# Focused searches
python src/code-security/scripts/search.py "file upload" --mode checklist
python src/code-security/scripts/search.py "sql injection" --mode vuln
python src/code-security/scripts/search.py "password hashing" --mode crypto
python src/code-security/scripts/search.py "database query" --mode rules --lang javascript
python src/code-security/scripts/search.py "authentication" --mode asvs
python src/code-security/scripts/search.py "memory buffer" --mode cwe
python src/code-security/scripts/search.py "sast sbom secret scanning" --mode controlSearch results are ranked using a BM25 and keyword hybrid search. Common Traditional Chinese security queries are supported.
Validate all CSV schemas, required standards coverage, ASVS totals, CWE coverage, and assurance-control review dates:
python src/code-security/scripts/validate_data.pyRun the automated tests:
python -m unittest discover -s tests -vGitHub Actions runs both commands on every push and pull request. The current workflow validates the knowledge base and Python search behavior; it does not yet perform end-to-end tests of every AI integration or act as a project-wide SAST scanner.
code-security-skill/
|-- README.md
|-- package.json
|-- bin/
| `-- codesecurity.js # npm CLI
|-- scripts/
| `-- install_skill.py # Multi-platform installer/uninstaller
|-- src/
| `-- code-security/
| |-- data/ # Versioned security knowledge base
| |-- scripts/
| | |-- search.py # BM25 and keyword search
| | `-- validate_data.py # Schema and coverage validation
| |-- templates/ # Always-on AI instruction templates
| `-- mcp_server.py # Local stdio MCP server
|-- tests/
| `-- test_search.py
`-- .github/workflows/test.yml
- Confirm
python -m pip show mcpsucceeds. - Confirm
~/.code-security-skill/mcp_server.pyexists. - Inspect the platform-specific MCP configuration listed above.
- Restart or reload the AI coding tool.
- Re-run installation with
--forceif the configuration is stale.
Try python3 on Unix-like systems or py -3 on Windows. Ensure the selected
interpreter is available on PATH.
MCP tool invocation is controlled by the AI client. Ask it explicitly to use
search_security, confirm the static rules file is loaded, and verify that the
client has enabled the code-security MCP server.
This is intentional. Run the installer from a separate target project. The
repository keeps only src/code-security as its source of truth.
This project helps AI assistants retrieve and apply secure-development guidance. It cannot guarantee vulnerability-free code and does not:
- automatically scan every source file;
- execute SAST, DAST, SCA, secret scanning, fuzzing, or penetration tests;
- verify runtime configuration or infrastructure;
- replace project-specific threat modeling or expert review.
For production systems, enforce security independently in CI/CD and during review. Treat AI-generated security decisions as recommendations that require verification.
Contributions are welcome. Useful areas include:
- vulnerability profiles and precise CWE mappings;
- additional language and framework rules;
- new feature-specific security checklists;
- MCP and installer integration tests;
- references, test cases, and knowledge-base validation.
Before submitting changes:
python src/code-security/scripts/validate_data.py
python -m unittest discover -s tests -v- OWASP Top 10 2025
- OWASP API Security Top 10 2023
- OWASP Top 10 for LLM Applications
- OWASP ASVS 5.0.0
- OWASP Cheat Sheet Series
- MITRE CWE Top 25 2025
- NIST Cybersecurity Framework
MIT, as declared in package.json.