Skip to content
Back to skills

Collection

ASecurity

TRUST 4 principles - Test First, Readable, Unified, Secured

  • 24 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
testingpythonrustgobashtestingci/cdsecuritydocumentation

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add mattnigh/skills_collection --skill collection --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Collection?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Collection
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mattnigh-collection-44d2a707/badge)](https://www.skillsdirectory.com/skills/mattnigh-collection-44d2a707)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: moai-foundation-trust
version: 4.0.0
updated: 2025-11-20
status: stable
tier: foundation
description: TRUST 4 principles - Test First, Readable, Unified, Secured
allowed-tools: [Read, Bash, WebSearch, WebFetch]
---

# TRUST 4 Principles

**Foundation of Code Quality**

> **Principles**: Test First, Readable, Unified, Secured  
> **Standards**: ≥85% Coverage, Pylint ≥8.0, OWASP Top 10

---

## Overview

TRUST 4 defines non-negotiable quality requirements for all code.

### The Four Principles

1.  **T**est First: Write tests before implementation.
2.  **R**eadable: Clarity over cleverness.
3.  **U**nified: Consistent patterns across codebase.
4.  **S**ecured: OWASP compliance by design.

---

## Principle 1: Test First (T)

### TDD Cycle

1.  **RED**: Write failing test.
2.  **GREEN**: Implement minimal code to pass.
3.  **REFACTOR**: Improve without breaking tests.

### Coverage Targets

- **Unit Tests**: 70% (fast, specific)
- **Integration Tests**: 20% (cross-component)
- **E2E Tests**: 10% (full workflow)
- **Total**: ≥85%

### Example

```python
# 1. RED: Write test (fails)
def test_password_hash_unique():
    hash1 = hash_password("TestPass123")
    hash2 = hash_password("TestPass123")
    assert hash1 != hash2

# 2. GREEN: Implement
def hash_password(plaintext: str) -> str:
    import bcrypt
    salt = bcrypt.gensalt(rounds=12)
    return bcrypt.hashpw(plaintext.encode(), salt).decode()

# 3. REFACTOR: Add security docs
```

---

## Principle 2: Readable (R)

### Metrics

- **Cyclomatic Complexity**: ≤10
- **Function Length**: ≤50 lines
- **Nesting Depth**: ≤3 levels

### Rules

- Clear naming (`validate_password` not `vp`)
- Single responsibility per function
- Docstrings for all functions
- Consistent style (PEP 8, Black, Prettier)

### Example

```python
# Bad
def f(x, y):
    return sum([i*x for i in y if i]) / len(y) if y else 0

# Good
def calculate_weighted_average(weight: float, values: List[float]) -> float:
    """Calculate weighted average, excluding None values."""
    valid = [v for v in values if v is not None]
    if not valid:
        return 0.0
    return sum(v * weight for v in valid) / len(valid)
```

---

## Principle 3: Unified (U)

### Consistency Rules

- Same file structure across modules
- Same naming for same concepts (`user_id` everywhere, not `uid`)
- Same error handling patterns
- Same logging approach

### Example Pattern

```python
# Unified error handling
try:
    result = process_payment(order)
except PaymentError as e:
    logger.error(f"Payment failed: {e}", extra={"order_id": order.id})
    raise ApplicationError("Payment processing failed") from e
```

---

## Principle 4: Secured (S)

### OWASP Top 10 (2024)

1.  **Broken Access Control**: Implement RBAC
2.  **Cryptographic Failures**: Use bcrypt (not MD5), TLS 1.3+
3.  **Injection**: Parameterized queries
4.  **Insecure Design**: Threat modeling
5.  **Security Misconfiguration**: Secrets management
6.  **Vulnerable Components**: Regular updates (pip audit)
7.  **Auth Failures**: MFA, rate limiting
8.  **Data Integrity**: Code signing
9.  **Logging Failures**: Comprehensive logs
10. **SSRF**: Input validation

### Example

```python
def hash_password(plaintext: str) -> str:
    """
    OWASP A02:2021 compliant password hashing.
    Uses bcrypt with 12 rounds (2025 standard).
    """
    import bcrypt
    if not plaintext:
        raise ValueError("Password required")

    salt = bcrypt.gensalt(rounds=12)
    return bcrypt.hashpw(plaintext.encode(), salt).decode()
```

---

## Validation Checklist

- [ ] **Test**: Coverage ≥85%?
- [ ] **Readable**: Pylint ≥8.0?
- [ ] **Unified**: Patterns consistent?
- [ ] **Secured**: OWASP scan passed (bandit, pip audit)?

---

## CI/CD Quality Gates

```bash
# Automated quality gate
pytest --cov=src --cov-fail-under=85  # T: Test
pylint src/ --fail-under=8.0           # R: Readable
bandit -r src/ -ll                     # S: Secured
```

---

## Related Skills

- `moai-core-rules`: Core development guidelines
- `moai-security-devsecops`: Security testing
- `moai-project-documentation`: Documentation standards

---

**Last Updated**: 2025-11-20

Files in this skill

  • 0Chan-smc__claude-code-workflow-lab__claude__skills__frontend-dev-guidelines__SKILL.md15.1 KB
  • 17hz__nextjs-template__claude__skills__example-skill__SKILL.md316 B
  • 1ambda__dataops-platform__claude__skills__context-synthesis__SKILL.md3.5 KB
  • 1natsu172__dotfiles__claude__skills__git-analysis__SKILL.md5.4 KB
  • 1natsu172__dotfiles__claude__skills__github-pr-best-practices__SKILL.md7.7 KB
  • 23Maestro__prospect-pipeline__claude__skills__npid-fastapi-skill.md26.1 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-javascript__SKILL.md15.7 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-code-python__SKILL.md17.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-expression-syntax__SKILL.md9.4 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-mcp-tools-expert__SKILL.md12.5 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-node-configuration__SKILL.md16.6 KB
  • 360AYA25__ClaudeN8N__claude__skills__n8n-workflow-patterns__SKILL.md11.2 KB
  • 3x-Projetos__claude-memory-framework__claude__skills__scientist__SKILL.md14.8 KB
  • 5MinFutures__futures-arena__claude__skills__migration-tracker__SKILL.md16.2 KB
  • 5MinFutures__futures-arena__claude__skills__planning-guidelines__SKILL.md11.8 KB
  • 92Bilal26__TaskPilotAI__claude__skills__assessment-builder__SKILL.md17.5 KB
  • 92Bilal26__TaskPilotAI__claude__skills__book-scaffolding__SKILL.md19.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__code-validation-sandbox__SKILL.md6.2 KB
  • 92Bilal26__TaskPilotAI__claude__skills__exercise-designer__SKILL.md18.1 KB
  • 92Bilal26__TaskPilotAI__claude__skills__learning-objectives__SKILL.md24.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in testing →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.