mycop
CLAUDE.md9 starsChanged 10 months agoMITView on GitHub
mycop is an AI-powered code security scanner (SAST) written in Rust. It detects vulnerabilities in AI-generated code targeting Python, JavaScript, TypeScript, Go, and Java, with 200 built-in YAML security rules covering OWASP Top 10 and CWE Top 25. CI runs on both Ubuntu and macOS with stable Rust. All PRs must pass fmt, clippy, build, and test. CLI parsing (clap) → Config loading (.scanrc.yml) → File discovery (walkdir + gitignore) → Rule loading (embedded YAML via include_str!) → Parallel scanning…
1 other project uses a version of this.
Adopted by
Most recently taken up by
- surd-pollywog583/mycopword for word, first seen Feb 15, 2026
Other versions1 project uses a version of this.
Word for word · 1
- surd-pollywog583/mycop★ 2100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repositoryOne other file it gives its agents.
- docs/llms.txtllms.txt
The file
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
What is mycop
mycop is an AI-powered code security scanner (SAST) written in Rust. It detects vulnerabilities in AI-generated code targeting Python, JavaScript, TypeScript, Go, and Java, with 200 built-in YAML security rules covering OWASP Top 10 and CWE Top 25.
Build & Development Commands
cargo build # Debug build
cargo build --release # Optimized release build
cargo test --verbose # Run all tests
cargo test scanner_tests # Run a specific test module
cargo fmt --all -- --check # Check formatting (CI enforced)
cargo clippy --all-targets -- -D warnings # Lint (CI enforced, warnings are errors)CI runs on both Ubuntu and macOS with stable Rust. All PRs must pass fmt, clippy, build, and test.
Architecture
Data Flow
CLI parsing (clap) → Config loading (.scanrc.yml) → File discovery (walkdir + gitignore) → Rule loading (embedded YAML via include_str!) → Parallel scanning (Rayon) → Severity filtering → Optional AI processing → Output reporting
Module Map (src/)
- cli.rs — Clap-derived CLI definitions. Subcommands:
scan,fix,review,init,rules list,deps check,mcp - main.rs — Command routing and orchestration for all subcommands
- scanner/ — Core scanning engine
engine.rs— Parallel file scanning with Rayon (scan_filesreturnsVec<Finding>)language.rs— Language detection from file extensions (Python, JS, TS, Go, Java)file_discovery.rs— File globbing, gitignore-aware traversal,--diffmode via git
- rules/ — Security rule system
registry.rs— Loads 200 YAML rules embedded at compile time viainclude_str!fromrules/python/,rules/javascript/,rules/go/, andrules/java/matcher.rs— Pattern matching using tree-sitter AST queries + regex. ProducesFindingstructsparser.rs— YAML rule deserialization
- ai/ — Pluggable AI backends behind the
AiBackendtraittypes.rs—AiBackendtrait withexplain(),deep_review(),fix_file()methodsmod.rs— Auto-detection and factory (detect_ai_provider,create_backend). Priority: Claude CLI → Anthropic API → OpenAI API → Ollama → rule-based fallback- Provider impls:
claude_cli.rs,anthropic.rs,openai.rs,ollama.rs,rule_based.rs prompt.rs— Prompt templates for AI interactions
- fixer.rs — Auto-fix flow: groups findings per file, sends to AI, extracts
<FIXED_FILE>tags from response, generates diffs, optionally writes back and re-scans for verification. Also providesdiff_to_string()for generating plain-text diffs - mcp/ — MCP (Model Context Protocol) server for agentic tool integration
mod.rs—MycopMcpServerstruct implementingServerHandlertrait. Handleslist_tools,call_tool,list_resources,read_resource. Starts STDIO transport viaMycopMcpServer::run()tools.rs— 5 MCP tools implemented onMycopMcpServerusing#[tool]proc macro:scan,list_rules,explain_finding,review,check_deps. Thefixtool is intentionally excluded from MCP — agentic tools should read scan findings and apply fixes themselves. Sync impl functions bridged to async viatokio::task::spawn_blocking. Tools registered viarmcp::tool_box!macrotypes.rs— MCP-specific request/response schemas withDeserialize + JsonSchema(inputs) andSerialize(outputs). Separate from core types to isolate MCP concernsconvert.rs— Conversions between core types (Finding,Rule) and MCP output types (FindingOutput,RuleOutput)
- reporter/ — Output formatters implementing the
Reportertraitterminal.rs(colored),json.rs,sarif.rs(for CI/IDE integration)
- config/scanrc.rs — Loads
.scanrc.yml/.mycop.ymlconfig (ignore patterns, min_severity, fail_on, ai_provider)
Rules (rules/)
200 YAML files (50 Python in rules/python/, 50 JavaScript in rules/javascript/, 50 Go in rules/go/, 50 Java in rules/java/). Each rule has: id, name, severity, CWE/OWASP mappings, pattern (regex and/or AST query), message, fix_hint. Rules are embedded into the binary at compile time.
Inline suppression: # mycop-ignore or # mycop-ignore:RULE-ID
Key Design Patterns
- Embedded rules — No external files needed at runtime; YAML rules compiled into the binary
- AST + regex dual matching — tree-sitter AST queries for structural analysis, regex for broader detection, with deduplication
- AI provider chain — Auto-detects available providers with graceful fallback
- Parallel scanning — Rayon parallel iterators with
Arc<Mutex>for collecting findings - Severity ordinals — Critical=4, High=3, Medium=2, Low=1, Info=0; default fail threshold is High
- MCP sync-to-async bridge — Core scanning uses Rayon (sync); MCP server uses tokio (async). Bridged with
tokio::task::spawn_blocking. All stdout reserved for JSON-RPC in MCP mode; diagnostics go to stderr - Separate MCP types —
FindingOutput/RuleOutputinstead of addingSerialize/JsonSchemato coreFinding/Rule, keeping MCP concerns isolated
Tests
Integration tests in tests/scanner_tests.rs with fixtures in tests/fixtures/. Tests cover file discovery, rule parsing, finding deduplication, config loading, and severity filtering.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

