agentleFS
Karanjot786Karanjot786/TermUI/.github/skills/code-reviewer/AGENTS.md

TermUI / code-reviewer

AGENTS.md237 starsChanged 5 months agoMITView on GitHub

A comprehensive guide for AI agents performing code reviews, organized by priority and impact. Impact: CRITICAL | Category: security | Tags: sql, security, injection, database Never construct SQL queries with string concatenation or f-strings. Always use parameterized queries to prevent SQL injection attacks. SQL injection is one of the most common and dangerous web vulnerabilities. Attackers can: - Access unauthorized data - Modify or delete database records - Execute admin operations on the database - In some cases, issue commands…

We split this AGENTS.md into the rules it gives an agent

5 rules. About 0 are common, 5 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never construct SQL queries with string concatenation or f-strings.

    line 31
  2. Distinctive:

    Never insert unsanitized user input into HTML.

    line 70
  3. Distinctive:

    Always handle errors explicitly.

    line 130
  4. Distinctive:

    Use type annotations to make code self-documenting and catch errors early.

    line 192
  5. Distinctive:

    When performing reviews, structure as:

    line 260

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Code Review Guidelines

A comprehensive guide for AI agents performing code reviews, organized by priority and impact.


Table of Contents

Security — CRITICAL

  1. SQL Injection Prevention
  2. XSS Prevention

Performance — HIGH

  1. Avoid N+1 Query Problem

Correctness — HIGH

  1. Proper Error Handling

Maintainability — MEDIUM

  1. Use Meaningful Variable Names
  2. Add Type Hints

Security

SQL Injection Prevention

Impact: CRITICAL | Category: security | Tags: sql, security, injection, database

Never construct SQL queries with string concatenation or f-strings. Always use parameterized queries to prevent SQL injection attacks.

Why This Matters

SQL injection is one of the most common and dangerous web vulnerabilities. Attackers can:

  • Access unauthorized data
  • Modify or delete database records
  • Execute admin operations on the database
  • In some cases, issue commands to the OS

❌ Incorrect

def get_user(user_id):
    query = f"SELECT * FROM users WHERE id = {user_id}"
    result = db.execute(query)
    return result

# Vulnerable to: get_user("1 OR 1=1")
# Returns all users!

✅ Correct

def get_user(user_id: int) -> Optional[Dict[str, Any]]:
    query = "SELECT * FROM users WHERE id = ?"
    result = db.execute(query, (user_id,))
    return result.fetchone() if result else None

➡️ Full details: security-sql-injection.md


XSS Prevention

Impact: CRITICAL | Category: security | Tags: xss, security, html, javascript

Never insert unsanitized user input into HTML. Always escape output or use frameworks that auto-escape by default.

❌ Incorrect

// Dangerous!
document.getElementById('username').innerHTML = userInput;

✅ Correct

// Safe: use textContent
element.textContent = userInput;

// Or sanitize if HTML needed
import DOMPurify from 'dompurify';
element.innerHTML = DOMPurify.sanitize(userHtml);

➡️ Full details: security-xss-prevention.md


Performance

Avoid N+1 Query Problem

Impact: HIGH | Category: performance | Tags: database, performance, orm, queries

The N+1 query problem occurs when code executes 1 query to fetch a list, then N additional queries to fetch related data for each item.

❌ Incorrect

# 101 queries for 100 posts!
posts = Post.objects.all()  # 1 query
for post in posts:
    print(f"{post.title} by {post.author.name}")  # N queries

✅ Correct

# 1 query with JOIN
posts = Post.objects.select_related('author').all()
for post in posts:
    print(f"{post.title} by {post.author.name}")  # No extra queries!

➡️ Full details: performance-n-plus-one.md


Correctness

Proper Error Handling

Impact: HIGH | Category: correctness | Tags: errors, exceptions, reliability

Always handle errors explicitly. Don't use bare except clauses or ignore errors silently.

❌ Incorrect

try:
    result = risky_operation()
except:
    pass  # Silent failure!

✅ Correct

try:
    config = json.loads(config_file.read())
except json.JSONDecodeError as e:
    logger.error(f"Invalid JSON in config file: {e}")
    config = get_default_config()
except FileNotFoundError:
    logger.warning("Config file not found, using defaults")
    config = get_default_config()

➡️ Full details: correctness-error-handling.md


Maintainability

Use Meaningful Variable Names

Impact: MEDIUM | Category: maintainability | Tags: naming, readability, code-quality

Choose descriptive, intention-revealing names. Avoid single letters (except loop counters), abbreviations, and generic names.

❌ Incorrect

def calc(x, y, z):
    tmp = x * y
    res = tmp + z
    return res

✅ Correct

def calculate_total_price(item_price: float, quantity: int, tax_rate: float) -> float:
    subtotal = item_price * quantity
    total_with_tax = subtotal + (subtotal * tax_rate)
    return total_with_tax

➡️ Full details: maintainability-naming.md


Add Type Hints

Impact: MEDIUM | Category: maintainability | Tags: types, python, typescript, type-safety

Use type annotations to make code self-documenting and catch errors early.

❌ Incorrect

def get_user(id):
    return users.get(id)

✅ Correct

def get_user(id: int) -> Optional[Dict[str, Any]]:
    """Fetch user by ID."""
    return users.get(id)

➡️ Full details: maintainability-type-hints.md


Quick Reference

Review Checklist

Security (CRITICAL - review first)

  • No SQL injection vulnerabilities
  • No XSS vulnerabilities
  • Secrets not hardcoded
  • Authentication/authorization checks present

Performance (HIGH)

  • No N+1 queries
  • Appropriate caching
  • No unnecessary database calls
  • Efficient algorithms

Correctness (HIGH) - [ ] Proper error handling

  • Edge cases handled
  • Input validation
  • No race conditions

Maintainability (MEDIUM)

  • Clear variable/function names
  • Type hints present
  • Code is DRY (Don't Repeat Yourself)
  • Functions are single-purpose

Testing

  • Tests cover new code
  • Edge cases tested
  • Error paths tested

Severity Levels

LevelDescriptionExamplesAction
CRITICALSecurity vulnerabilities, data loss risksSQL injection, XSS, auth bypassBlock merge, fix immediately
HIGHPerformance issues, correctness bugsN+1 queries, race conditionsFix before merge
MEDIUMMaintainability, code qualityNaming, type hints, commentsFix or accept with TODO
LOWStyle preferences, minor improvementsFormatting, minor refactoringOptional

Review Output Format

When performing reviews, structure as:

## Security Issues (X found)

### CRITICAL: SQL Injection in `get_user()`
**File:** `api/users.py:45`
**Issue:** User input interpolated directly into SQL query
**Fix:** Use parameterized query

## Performance Issues (X found)

### HIGH: N+1 Query in `list_posts()`
**File:** `views/posts.py:23`
**Issue:** Fetching author in loop
**Fix:** Add `.select_related('author')`

## Summary
- 🔴 CRITICAL: 1
- 🟠 HIGH: 1
- 🟡 MEDIUM: 3
- ⚪ LOW: 2

**Recommendation:** Address CRITICAL and HIGH issues before merging.

References

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

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.