Validate code changes against CI/CD requirements (lint, test, build, commit messages) for Go, Web, and Python subsystems before pushing
This skill ensures all code changes meet the One Percent Trading Bot platform's CI/CD requirements before pushing to remote. It encapsulates our comprehensive linting, testing, and build standards to prevent CI failures.
CRITICAL: Run this skill BEFORE every git push, BEFORE creating PRs, and AFTER making significant code changes.
This skill should be invoked:
git push)DO NOT run this skill:
The codebase is a monorepo with multiple subsystems. Detect which subsystems have changed and run appropriate checks:
Trigger when changed:
**/*.go filesgo.mod, go.sumhermelos/Dockerfile, janomus/Dockerfile.golangci.ymlChecks to run:
janomus and hermelosgolangci-lint configuration (.golangci.yml):
version: "2"
run:
timeout: 5m
go: "1.25.2"
formatters:
enable:
- goimports
settings:
goimports:
local-prefixes:
- "github.com/haykay/one-percent-trading-bot"
linters:
enable:
- errcheck
- govet
- ineffassign
- staticcheck
- unused
- forcetypeassert
Common Go lint failures:
errcheck)forcetypeassert)unused)Trigger when changed:
web/**Checks to run (from web/ directory):
npm run lintnpm run format:checknpm run typechecknpm run testnpm run buildCommon Web lint failures:
npm run format:fix to auto-fix)Trigger when changed:
pundora/**/*.pypundora/requirements*.txtChecks to run:
pip-audit -r pundora/requirements.txt --strictCommon Python lint failures:
Always check commit messages for ALL commits being pushed.
Format requirements:
<type>(<scope>): <Summary in sentence case>
Optional body with line length ⤠72 characters. Body should provide
additional context when the summary alone isn't sufficient.
Valid types: feat, fix, docs, style, refactor, test, chore, ci, perf, build
Valid scopes: api, auth, matrix, pundora, web, infra, k8s, ci, deps, config
Validation rules:
Common commit message failures:
Examples:
ā
feat(api): Add bridge activation (31 chars)
ā
fix(matrix): Handle rate limiting in sync loop (47 chars)
ā feat(api): Add comprehensive error handling for bridge activation failures (75 chars) - TOO LONG
ā Fix(api): Add auth (wrong case - "Fix" should be "fix")
ā feat(API): Add endpoint (wrong case - "API" should be "api")
Follow this systematic approach:
šØ NEVER allow commits or work to proceed on main/master branch!
# Check current branch
git branch --show-current
If on main or master:
STOP IMMEDIATELY - Do not proceed with any checks
Alert the user - Explain the branch protection policy
Guide recovery:
# If no commits yet - just switch branches
git checkout -b feature/my-feature
# If already committed to main (CRITICAL ERROR)
git branch feature/my-feature # Save commits
git reset --hard origin/main # Reset main
git checkout feature/my-feature # Switch to feature branch
Branch protection policy:
Branch naming conventions:
feature/description or name/descriptionfix/descriptionethan/fix-auth, feature/add-bridge# Get the main branch name
MAIN_BRANCH=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@' || echo "main")
# Get changed files since main
git diff --name-only "$MAIN_BRANCH"...HEAD
For ALL commits being pushed (not just the latest commit):
# Get commits being pushed (commits in current branch not in main)
git rev-list "$MAIN_BRANCH"..HEAD
# For each commit, validate with commitlint
git log -1 --format=%B <commit-sha> | npx commitlint
IMPORTANT: Validate the FULL commit message (title + body), not just the title. Many failures come from body line length violations.
šØ CRITICAL: Check PR Body Line Length Before Pushing
GitHub Actions validates the PR body separately from commits. This is a common source of CI failures:
The problem:
Prevention:
echo "text" | python3 -c "import sys; print(max(len(line.rstrip()) for line in sys.stdin))"If you must amend after pushing:
git push --force-with-leasegh api repos/haykay/one-percent-trading-bot/pulls/NNN --method PATCH --field body="$(git log -1 --format=%B)"Why this happens:
.github/workflows/commitlint.yml)Based on changed files detected in step 1, run the appropriate checks:
# Lint entire codebase
golangci-lint run
# Auto-fix where possible
golangci-lint run --fix
# Run tests with race detection
go test -race -cover ./...
# Build both services
go build -v -o hermelos/hermelos ./hermelos
go build -v -o janomus/janomus ./janomus
# Clean up build artifacts
rm -f hermelos/hermelos janomus/janomus
cd web
# Ensure dependencies installed
npm ci
# ESLint
npm run lint
# Prettier format check
npm run format:check
# TypeScript type check
npm run typecheck
# Tests
npm run test
# Production build
npm run build
cd ..
# Prefer .venv if exists, otherwise use system ruff
RUFF=".venv/bin/ruff"
if ! [ -x "$RUFF" ]; then
RUFF="ruff"
fi
PY_BIN=".venv/bin/python"
if ! [ -x "$PY_BIN" ]; then
PY_BIN="python"
fi
# Lint and auto-fix
$RUFF check --fix pundora/
# Format
$RUFF format pundora/
# Tests
$PY_BIN -m pytest pundora/server
# Security audit (optional but recommended)
pip-audit -r pundora/requirements.txt --strict
Provide a clear summary:
Success format:
ā
CI Compliance Check PASSED
Checked subsystems:
ā
Go services: lint, test, build
ā
Commit messages: 3 commits validated
All checks passed! Safe to push.
Failure format:
ā CI Compliance Check FAILED
Issues found:
ā Go services (golangci-lint):
- api/handlers/bridges.go:123: Error not checked (errcheck)
- common/synapse/client.go:45: Force type assertion (forcetypeassert)
ā Commit messages:
- Commit abc1234: Header too long (75 chars, max 72)
"feat(api): Add comprehensive error handling for bridge activation failures"
ā
Web console: All checks passed
Fix these issues before pushing. Some issues may be auto-fixable:
- Run: golangci-lint run --fix
- Rewrite commit message: git rebase -i main (edit the commit)
When failures are detected, attempt auto-fixes where possible:
npm run format:fix (auto-fixes formatting)npm run lint -- --fixgit rebase -i main to edit commit messagesWhen checks fail:
--no-verify unless user explicitly
requestsgo test -cover (not -coverprofile) to avoid file
I/O overheadThis skill mirrors the .husky/pre-push hook but provides:
Symptom:
File is not goimports-ed with -local github.com/haykay/one-percent-trading-bot
Cause: Imports not grouped correctly (stdlib, external, local)
Fix: Run golangci-lint run --fix or manually reorder imports:
import (
// Standard library
"context"
"fmt"
// External packages
"github.com/stretchr/testify/assert"
// Local packages
"github.com/haykay/one-percent-trading-bot/models"
)
Symptom: header-max-length: Header exceeds 72 characters
Cause: Summary too verbose
Fix: Make summary concise, move details to body:
ā feat(api): Add comprehensive error handling for bridge activation failures
ā
feat(api): Add bridge activation error handling
Add comprehensive error handling for bridge activation failures including
timeout handling, credential validation, and graceful degradation.
Symptom: Error return value is not checked (errcheck)
Cause: Function returns error but caller ignores it
Fix: Check and handle the error:
ā client.SendMessage(roomID, text)
ā
if err := client.SendMessage(roomID, text); err != nil {
return fmt.Errorf("failed to send message: %w", err)
}
Symptom: type assertion must be checked (forcetypeassert)
Cause: Type assertion without ok check
Fix: Use two-value form:
ā user := value.(*User)
ā
user, ok := value.(*User)
if !ok {
return fmt.Errorf("expected *User, got %T", value)
}
After running this skill, the user should:
User: "Check if my code is ready to push" ā Run full CI compliance check
User: "I'm getting golangci-lint failures" ā Run Go-specific checks with detailed error reporting
User: "Fix my commit messages" ā Validate commits and suggest rewrites for failures
User: "Run pre-push checks" ā Run full CI compliance check
--no-verify - Bypassing checks leads to CI failures