---
# Code Quality Standards

<!--
GENERATION INSTRUCTIONS:
1. Parse linter config for active rules
2. Extract formatter settings
3. Scan codebase for consistent patterns
4. Identify type checking strictness level
5. Find pre-commit/CI quality gates
6. Extract actual good/bad examples from codebase
7. Output: 150-250 lines max
-->

**Project**: [Extract from config]
**Linter**: [Detect tool + config file]
**Formatter**: [Detect tool + config file]
**Type Checker**: [Detect tool + config file or N/A]

---

## Quality Commands

<!-- Extract exact commands from package.json, Makefile, pyproject.toml -->

| Action | Command | Description |
|--------|---------|-------------|
| Check all | `[combined command if exists]` | Run all quality checks |
| Lint | `[lint command]` | Check code issues |
| Lint fix | `[lint fix command]` | Auto-fix issues |
| Format | `[format command]` | Format code |
| Type check | `[type check command or N/A]` | Verify types |

**Before committing, run**: `[primary quality command]`

---

## Enforced Rules

<!-- Extract key rules from linter/formatter config -->

### From Linter (`[config file]`)

| Rule | Setting | Rationale |
|------|---------|-----------|
| `[rule-name]` | `[error/warn/value]` | [Brief why] |
| `[rule-name]` | `[error/warn/value]` | [Brief why] |
| `[rule-name]` | `[error/warn/value]` | [Brief why] |
| `[rule-name]` | `[error/warn/value]` | [Brief why] |

### From Formatter (`[config file]`)

| Setting | Value |
|---------|-------|
| Line length | `[value]` |
| Indentation | `[tabs/spaces, size]` |
| Quotes | `[single/double]` |
| Trailing comma | `[yes/no/es5]` |
| Semicolons | `[yes/no]` |

---

## Naming Standards

<!-- Extract from linter rules + analyze codebase patterns -->

| Element | Rule | ✅ Correct | ❌ Wrong |
|---------|------|-----------|----------|
| Variables | `[camelCase/snake_case]` | `userName` | `user_name` / `UserName` |
| Functions | `[camelCase/snake_case]` | `getUserById` | `GetUserById` |
| Classes | `[PascalCase]` | `UserService` | `userService` |
| Constants | `[UPPER_SNAKE]` | `MAX_RETRIES` | `maxRetries` |
| Files | `[kebab/snake/pascal]` | `[actual example]` | `[counter example]` |
| Boolean vars | `[is/has/should prefix]` | `isActive` | `active` |

---

## Type Safety

<!-- Detect type checking level and requirements -->

**Strictness**: `[strict / moderate / basic / none]`
**Config**: `[tsconfig.json / mypy.ini / pyproject.toml section]`

### Required Typing

```[lang]
// ✅ Correct - Source: [file:lines]
[Extract well-typed function example]

// ❌ Missing types - would fail type check
[Show same function without types]
```

### Type Rules

| Rule | Required |
|------|----------|
| Function parameters | ✅ Always |
| Function returns | ✅ Always |
| Variables | `[inferred OK / explicit required]` |
| `any` / `unknown` | `[forbidden / discouraged / allowed]` |

---

## Code Complexity Limits

<!-- Extract from linter config or establish from codebase patterns -->

| Metric | Limit | Enforced By |
|--------|-------|-------------|
| Function length | `[max lines]` | `[rule name or convention]` |
| File length | `[max lines]` | `[rule name or convention]` |
| Cyclomatic complexity | `[max value]` | `[rule name or N/A]` |
| Nesting depth | `[max levels]` | `[rule name or convention]` |
| Parameters per function | `[max count]` | `[rule name or convention]` |

### Reduce Complexity

```[lang]
// ❌ Too complex
[Extract or create example of deep nesting/long function]

// ✅ Refactored
[Show extracted/simplified version]
```

---

## Import Organization

<!-- Extract from linter rules (import-order, isort, etc.) -->

```[lang]
// Source: [well-organized file:lines]

// Group 1: [Built-in/Standard library]
[imports]

// Group 2: [External/Third-party packages]
[imports]

// Group 3: [Internal/Local modules]
[imports]
```

**Rules**:
- ✅ Sorted alphabetically within groups
- ✅ One import per line (or `[grouped style if used]`)
- ❌ Wildcard imports (`import *`)
- ❌ Unused imports

---

## Documentation Standards

<!-- Extract from docstring linter rules or conventions -->

### Required Documentation

| Element | Required | Format |
|---------|----------|--------|
| Public functions | ✅ | `[JSDoc / docstring / etc.]` |
| Public classes | ✅ | `[format]` |
| Complex logic | ✅ | Inline comments |
| Private/internal | Optional | - |

### Format

```[lang]
// Source: [file:lines]
[Extract canonical documentation example]
```

---

## Common Violations & Fixes

<!-- Extract from common linter errors in codebase or CI logs -->

| Violation | Fix |
|-----------|-----|
| `[linter-error-code]`: [description] | [How to fix] |
| `[linter-error-code]`: [description] | [How to fix] |
| `[linter-error-code]`: [description] | [How to fix] |
|