Files
semgrep__skills/packages/skill-build
Drew Dennison 823e429b92 Add llm-security skill and make build tooling generic
- Add llm-security skill covering OWASP Top 10 for LLM Applications 2025
  - 10 rules: Prompt Injection, Sensitive Disclosure, Supply Chain,
    Data Poisoning, Output Handling, Excessive Agency, System Prompt
    Leakage, Vector/Embedding Weaknesses, Misinformation, Unbounded
    Consumption
  - Python code examples with vulnerable/secure patterns

- Rename packages/code-security-build to packages/skill-build
  - Accept skill name as CLI argument: `pnpm validate llm-security`
  - Auto-discover skills with rules/ directories
  - Support Vulnerable/Secure labels (in addition to Incorrect/Correct)

- Update Makefile to build all skills automatically
  - `make validate` - validates all skills
  - `make build` - builds AGENTS.md for all skills
  - `make validate-skill SKILL=name` - single skill operations

- Update READMEs with llm-security documentation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-15 14:59:55 -08:00
..

Code Security Build Tools

Build tooling for validating, compiling, and testing the code-security skill.

Overview

This package provides tools to:

  • Validate rule files follow the correct format
  • Build compiled outputs (AGENTS.md, test-cases.json)
  • Extract test cases for LLM evaluation

Installation

pnpm install

Scripts

Command Description
pnpm validate Validate all rule files in skills/code-security/rules/
pnpm build Build AGENTS.md and extract test cases
pnpm build-agents Build only AGENTS.md
pnpm extract-tests Extract test cases to JSON
pnpm dev Build and validate

Rule Validation

The validator checks that each rule file has:

  • Valid frontmatter with title and impact
  • Main heading using ##
  • At least one **Incorrect:** example with code
  • At least one **Correct:** example with code
  • Valid impact level (CRITICAL, HIGH, MEDIUM, LOW)

Example Valid Rule

---
title: Prevent SQL Injection
impact: CRITICAL
tags: security, sql
---

## Prevent SQL Injection

Never concatenate user input into SQL queries.

**Incorrect (vulnerable):**

```python
query = f"SELECT * FROM users WHERE id = {user_id}"

Correct (parameterized):

query = "SELECT * FROM users WHERE id = %s"
cursor.execute(query, (user_id,))

## Architecture

src/ ├── validate.ts # Rule file validation ├── build.ts # AGENTS.md compilation ├── extract-tests.ts # Test case extraction ├── parser.ts # Markdown parser for rules ├── types.ts # TypeScript type definitions └── config.ts # Configuration (paths, etc.)


## Configuration

Rules are read from: `../../skills/code-security/rules/`

Files starting with `_` are excluded (e.g., `_template.md`, `_sections.md`).

## Usage from Root

You can also use the Makefile from the repo root:

```bash
make validate   # Runs pnpm validate
make build      # Runs pnpm build
make zip        # Creates skill zip package
make            # All of the above

Development

# Run validation during development
pnpm dev

# Just validate
pnpm validate

# Full build
pnpm build