Skip to content

AI Gateway enforces code quality through automated linting, type checking, formatting, security scanning, and git hooks. This page documents every tool in the stack and how they are configured.

Ruff handles both linting and formatting. Configuration is in ruff.toml.

Key settings:

SettingValue
Target versionPython 3.13
Line length120 characters
Quote styleDouble quotes
Indent styleSpaces
Docstring code formatEnabled

Enabled rule sets (30+):

CodeRule SetWhat It Catches
E / WpycodestylePEP 8 errors and warnings
FpyflakesUnused imports, undefined names, redefined variables
IisortImport ordering
Npep8-namingNaming convention violations
UPpyupgradeOutdated Python syntax (upgrades to 3.13 idioms)
Sflake8-banditSecurity issues (assert, exec, eval, hardcoded passwords)
Bflake8-bugbearLikely bugs and design problems
Aflake8-builtinsShadowing Python builtins
C4flake8-comprehensionsUnnecessary list/dict/set comprehensions
DTZflake8-datetimezNaive datetime usage (missing tzinfo)
T10flake8-debuggerLeftover debugger statements
EMflake8-errmsgException message formatting
LOGflake8-loggingLogging best practices
Gflake8-logging-formatLogging format string issues
PIEflake8-pieMiscellaneous lint (unnecessary pass, dict comprehension)
PTflake8-pytest-stylepytest best practices
RETflake8-returnUnnecessary return/else patterns
SIMflake8-simplifySimplifiable code patterns
TCHflake8-type-checkingImports that should be in TYPE_CHECKING blocks
ARGflake8-unused-argumentsUnused function arguments
PTHflake8-use-pathlibos.path usage that should be pathlib
ERAeradicateCommented-out code
PLpylintPylint rules (conventions, refactoring, warnings, errors)
TRYtryceratopsException handling anti-patterns
FLYflyntString concatenation that should be f-strings
PERFperflintPerformance anti-patterns
FURBrefurbModern Python refactoring suggestions
RUFruff-specificRuff’s own rules (ambiguous characters, mutable defaults)

Ignored rules:

RuleReason
S101Allow assert in tests
TRY003Allow long exception messages
EM101 / EM102Allow string/f-string literals in exceptions

Per-file ignores:

  • tests/**/*.py: S101 (assert), ARG (unused arguments in fixtures), PLR2004 (magic numbers)

Commands:

Terminal window
# Check for violations
mise run lint
# Auto-format and fix
mise run format

Pyright provides static type checking. Configuration is in pyrightconfig.json.

SettingValue
Type checking modestandard
Includesrc/
Exclude__pycache__, tests
Python version3.13
PlatformLinux
Report missing importsYes
Report unused importsYes
Report unused variablesYes

Command:

Terminal window
mise run typecheck

Pytest is used for testing. Tests live in the tests/ directory.

Local execution:

Terminal window
# Full test suite (verbose)
mise run test
# Quick check (fail-fast, quiet -- used by pre-push hook)
uv run pytest tests/ -x -q

Conventions:

  • Test files: tests/test_*.py or tests/**/test_*.py
  • Test functions: def test_*():
  • Fixtures: Defined in conftest.py files at the appropriate directory level
  • Markers: Use @pytest.mark.<marker> for test categorization

Source watching: The test task in mise.toml has sources = ["src/**/*.py", "tests/**/*.py"], so mise can skip re-running if no Python files changed.

Enforces the standard HCL formatting. The pre-commit hook checks formatting; mise run format auto-fixes it.

Terminal window
# Check only
terraform -chdir=infrastructure fmt -check -recursive
# Auto-fix
mise run tf:fmt

Validates that all Terraform configuration is syntactically correct and internally consistent.

Terminal window
mise run tf:validate

TFLint with the AWS ruleset provides Terraform-specific linting. Configuration is in infrastructure/.tflint.hcl.

Enabled rules:

RuleWhat It Checks
terraform_naming_conventionConsistent naming for resources, variables, outputs
terraform_documented_outputsAll outputs have descriptions
terraform_documented_variablesAll variables have descriptions
terraform_typed_variablesAll variables have explicit types
terraform_unused_declarationsNo unused variables, locals, or data sources
AWS ruleset (v0.38.0)AWS-specific rules (valid instance types, regions, etc.)

Disabled rules:

RuleReason
terraform_standard_module_structureModule structure is intentionally simplified (no versions.tf per child module)

Checkov scans Terraform for security misconfigurations against 2,500+ policies. Results are uploaded as SARIF to the GitHub Security tab.

Terminal window
mise run security:iac

terraform-docs auto-generates documentation for the infrastructure module. The pre-commit hook regenerates and stages the README; CI verifies it is up to date.

Terminal window
mise run tf:docs

Configuration in .terraform-docs.yml:

  • Output format: Markdown table
  • Sections: header, requirements, providers, modules, resources, inputs, outputs
  • Sort: By required status
  • Injection mode: Updates existing infrastructure/README.md in-place

Lefthook manages all git hooks. Configuration is in lefthook.yml.

HookGlob FilterAuto-stages Fixes
ruff lint (--fix)*.pyYes
ruff format*.pyYes
pyright*.pyNo
gitleaks protectAll stagedNo
hadolintDockerfile*No
terraform fmt (check)infrastructure/**/*.tfNo
terraform validateinfrastructure/**/*.tfNo
terraform-docsinfrastructure/**/*.tfYes
HookScope
pytest (-x -q)tests/ (fail-fast)
semgrepFull repo (OWASP Top 10, quiet)
checkovinfrastructure/ (compact, quiet)
trivy fsFull repo (HIGH + CRITICAL, quiet)

Validates Conventional Commits format: <type>(<scope>): <description> with max 72-character first line.

The .github/CODEOWNERS file enforces review requirements:

# Default owner for everything
* @theagenticguy
# Infrastructure requires explicit review
infrastructure/ @theagenticguy

All PRs require review from @theagenticguy. Infrastructure changes have an additional explicit rule to ensure they are always reviewed.

The project uses 12 security tools across development, CI, and deployment phases.

ToolCategoryWhat It CoversWhere It Runs
SemgrepSASTPython code analysis (OWASP Top 10, security audit)Pre-push hook, CI
GitleaksSecretsPrevents secrets from entering the repositoryPre-commit hook, CI
CheckovIaCTerraform security and compliance (2,500+ policies)Pre-push hook, CI
HadolintDockerfileDockerfile best practices with ShellCheck integrationPre-commit hook, CI
TrivyContainer + FSVulnerability scanning of images and filesystem (HIGH + CRITICAL)Pre-push hook, CI
SyftSBOMCycloneDX software bill of materials generationCI, Release
CosignSigningKeyless image signing via Sigstore OIDCCI (main push), Release
CodeQLCode analysisGitHub-native semantic code analysis (SARIF upload)CI, Weekly schedule
OpenSSF ScorecardSupply chainSupply chain security posture assessmentCI (main push), Weekly
Dependency ReviewDependenciesPR-time vulnerability and license check (denies GPL-3.0, AGPL-3.0)PR only
DependabotDependenciesAutomated updates for Python, Terraform, and GitHub ActionsWeekly Monday 08:00 ET
TFLintIaCTerraform linting with AWS rulesetCI

The .editorconfig file ensures consistent formatting across editors:

File PatternIndentSizeLine Length
*.pySpaces4120
*.tfSpaces2
*.{toml,yaml,yml}Spaces2
Dockerfile*Spaces4
MakefileTabs

Global settings (all files):

  • Line endings: LF (end_of_line = lf)
  • Final newline: Yes
  • Trailing whitespace: Trimmed
  • Charset: UTF-8