CI/CD & Build Stabilization Skill
This skill provides a systematic approach to resolving common CI/CD failures, frontend build conflicts, and linting blockers in modern full-stack projects.
1. Frontend Build & ESM Compatibility
When a Next.js project uses "type": "module" in package.json, generic .js config files are treated as ES modules.
- •The Problem:
module.exportsinnext.config.jsthrowsReferenceError: module is not defined. - •The Fix:
- •Rename
next.config.jstonext.config.mjs. - •Change
module.exports = nextConfig;toexport default nextConfig;.
- •Rename
2. ESLint 9 Flat Config Migration
ESLint 9 uses eslint.config.js by default. Legacy .eslintrc.json files or misplaced configs can cause directory resolution errors (e.g., Failed to fill directory in Next.js).
- •Best Practice:
- •Use a single
eslint.config.jsin the project root. - •Explicitly ignore
next-env.d.tsand build artifacts. - •If rules are too strict for production blockers, use
rules: { 'rule-name': 'off' }sparingly.
- •Use a single
3. React Hooks: setState in Effect
React hooks flagging setState inside useEffect can block builds if strict linting is enabled.
- •The Fix: Wrap synchronous state updates in a
setTimeout(() => { ... }, 0)orwindow.requestAnimationFrameto ensure the update happens after the current render cycle. - •Example:
typescript
useEffect(() => { const timeoutId = setTimeout(() => { setData(initialData); }, 0); return () => clearTimeout(timeoutId); }, []);
4. GitHub Actions Infrastructure
Common workflow failures often stem from missing setup steps or invalid versions.
- •Docker Caching: To use
type=ghacache, you must adddocker/setup-buildx-action@v3. - •Trivy Versioning: Always use valid semver tags like
0.33.1instead ofv0.20.0if the action registry requires it. - •Permissions: SARIF uploads for security scans require
security-events: writeandactions: read.
5. Backend Linting (Python/uv/ruff)
When using uv for Python management:
- •Installation: Use
uv sync --extra devin CI to ensure testing/linting tools are available. - •Automatic Fixes: Run
uv run ruff check --fix --unsafe-fixes .to clear bulk issues. - •Stabilization: If non-critical linting errors block the build, use
--exit-zeroin the CI command to report warnings without failing the job.
6. Docker Consistency
Always ensure the Dockerfile uses the same package manager as the local environment (e.g., npm vs yarn) to avoid lockfile mismatches.