https://github.com/semgrep/ai-best-practices
Semgrep Pro Rules to ensure code using LLMs is following best practices
https://github.com/semgrep/ai-best-practices
Last synced: 12 days ago
JSON representation
Semgrep Pro Rules to ensure code using LLMs is following best practices
- Host: GitHub
- URL: https://github.com/semgrep/ai-best-practices
- Owner: semgrep
- License: other
- Created: 2026-03-03T23:13:06.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2026-03-25T21:40:22.000Z (4 months ago)
- Last Synced: 2026-05-12T16:46:26.799Z (2 months ago)
- Size: 135 KB
- Stars: 71
- Watchers: 0
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
- awesome-ai-security - ai-best-practices - _Semgrep Pro Rules to ensure code using LLMs is following best practices. 58 rules, 102 sub-rules covering 6 providers + MCP + Claude Code & Cursor hooks + LangChain. Detects hardcoded API keys, prompt injection risks, missing safety checks, and unhandled errors across 7 languages._ (Attack Techniques & Red Teaming / LLM & GenAI Red Teaming)
README
# AI Best Practices — Semgrep Rules
> **This repository has been deprecated.** All rules have been migrated to the official Semgrep registry.
## Where to find the rules
The rules now live in the official Semgrep rules repository:
**Source:** [github.com/semgrep/semgrep-rules/tree/develop/ai/ai-best-practices](https://github.com/semgrep/semgrep-rules/tree/develop/ai/ai-best-practices)
**Rule pack:** [semgrep.dev/p/ai-best-practices](https://semgrep.dev/p/ai-best-practices)
## Quick Start
```bash
pip install semgrep
semgrep --config "p/ai-best-practices" /path/to/your/project/
```
## CI/CD Integration
### GitHub Actions
```yaml
name: AI Safety Lint
on: [pull_request]
jobs:
semgrep:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: semgrep/semgrep-action@v1
with:
config: "p/ai-best-practices"
```
### GitLab CI
```yaml
semgrep:
image: semgrep/semgrep
script:
- semgrep --config "p/ai-best-practices" --error .
rules:
- if: $CI_MERGE_REQUEST_IID
```
## License
See [LICENSE](LICENSE) for details.