# =============================================================================
# ๐ ๏ธ PRE-COMMIT CONFIG - FAST-TIME-SERVER (Go project)
# =============================================================================
# Install / run:
# pip install --user pre-commit
# pre-commit install
# pre-commit run --all-files
#
# To skip checks:
# git commit -m "msg" --no-verify
#
# To update:
# pre-commit autoupdate # optional: bumps other hooks to latest pinned tags
# pre-commit install # (re-installs the git hook if needed)
# pre-commit run --all-files
# =============================================================================
repos:
# ---------------------------------------------------------------------------
# ๐ Security / secret detection
# ---------------------------------------------------------------------------
- repo: https://github.com/gitleaks/gitleaks
rev: v8.27.2
hooks:
- id: gitleaks
name: ๐ Gitleaks - Detect hard-coded secrets
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: detect-private-key
name: ๐ Detect Private Key
types: [text]
# ---------------------------------------------------------------------------
# โ AI artefact & placeholder blockers
# ---------------------------------------------------------------------------
- repo: local
hooks:
- id: forbid-content-reference
name: โ Forbid :contentReference
entry: ":contentReference"
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
- id: forbid-oai-citations
name: โ Forbid OpenAI Citations
entry: '\[oaicite:\?\?\d+\]'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
- id: forbid-ai-stock-phrases
name: โ Forbid AI Stock Phrases
entry: "(?i)(source=chatgpt.com|turn0search0|brevity| filecite|unchanged|as an ai language model|i am an ai developed by|this response was generated by|i don't have real-time information|i don't have access to real-time|i can't browse the internet|i cannot browse the internet|my knowledge cutoff|my training data|i'm not able to access|i don't have the ability to)"
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
- id: forbid-placeholder-citations
name: โ Forbid Placeholder Citations
entry: '\([A-Z][a-z]+,?\s+\d{4}\)'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
- id: forbid-source-placeholders
name: โ Forbid Source Placeholders
entry: '(?i)\(source:'
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
- id: forbid-malformed-code-fences
name: โ Forbid Malformed Code Fences
entry: "````+"
language: pygrep
types: [text]
exclude: ^\.pre-commit-config\.yaml$
- id: warn-ai-transitions
name: โ ๏ธ Warn AI Transition Phrases
entry: "(?i)(brevity|in conclusion,|to summarize,|it is important to note that|remember that|keep in mind that|it's worth noting that|please note that)"
language: pygrep
types: [text]
verbose: true
exclude: ^\.pre-commit-config\.yaml$
# ---------------------------------------------------------------------------
# ๐ค Unicode text normalisation (smart-quotes, ligatures, exotic spaces)
# ---------------------------------------------------------------------------
- repo: https://github.com/sirosen/texthooks
rev: 0.6.8
hooks:
- id: fix-smartquotes
name: ๐ Normalize Smart Quotes
- id: fix-ligatures
name: ๐ก Normalize Ligatures
- id: fix-spaces
name: โฃ Normalize Unicode Spaces
- id: forbid-bidi-controls
name: ๐ซ Forbid BiDi Unicode Controls
# ---------------------------------------------------------------------------
# ๐งน Generic formatting & whitespace
# ---------------------------------------------------------------------------
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: end-of-file-fixer
name: ๐งน Fix End of Files
stages: [pre-commit, pre-push, manual]
- id: trailing-whitespace
name: ๐งน Trim Trailing Whitespace
stages: [pre-commit, pre-push, manual]
- id: fix-byte-order-marker
name: ๐งน Fix UTF-8 BOM
- id: mixed-line-ending
name: ๐งน Mixed Line Ending
args: [--fix=lf]
# size / merge / symlink checks
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: destroyed-symlinks
- id: check-executables-have-shebangs
- id: check-shebang-scripts-are-executable
- id: forbid-new-submodules
- id: check-json
- id: check-yaml
- id: check-toml
- id: check-xml
- id: check-byte-order-marker
# YAML linter
- repo: https://github.com/adrienverge/yamllint
rev: v1.37.1
hooks:
- id: yamllint
name: โ
yamllint
args: [-c, .yamllint]
files: ^.*\.(yml|yaml)$
exclude: ^charts/
# CRLF / tab remover
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.5
hooks:
- id: remove-crlf
name: ๐ Remove CRLF
- id: remove-tabs
name: ๐ Remove Tabs
exclude: '(^|/)Makefile$|\.mk$'
# ---------------------------------------------------------------------------
# ๐น Go tool-chain (formatters + linters)
# ---------------------------------------------------------------------------
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
# Formatters
- id: go-fmt
- id: go-imports
# Vet / lints
- id: go-vet
- id: golangci-lint
- id: go-lint # deprecated but kept here intentionally
- id: go-critic
# Complexity / metrics
- id: go-cyclo
args: ['-over=15']
# Build & test
- id: go-build
- id: go-unit-tests
# Module hygiene
- id: go-mod-tidy
# Misc checks
- id: validate-toml
- id: no-go-testing
- repo: https://github.com/segmentio/golines
rev: v0.12.2
hooks:
- id: golines
name: ๐งน golines - wrap long lines
args: ["--max-len=120", "--base-formatter=gofumpt"]
# ---------------------------------------------------------------------------
# ๐ OPTIONAL / web / extras (commented-out, keep for future)
# ---------------------------------------------------------------------------
#
# - repo: https://github.com/pre-commit/mirrors-prettier
# rev: v3.0.3
# hooks:
# - id: prettier
#
# - repo: https://github.com/igorshubovych/markdownlint-cli
# rev: v0.45.0
# hooks:
# - id: markdownlint