CI Integration
Screenbook is designed to be CI-first. By running lint checks in your CI pipeline, you can prevent documentation drift and ensure all screens have metadata.
Quick Setup
Section titled “Quick Setup”Add the lint command to your CI workflow:
- name: Lint Screenbook run: npx screenbook lintWhat lint Checks
Section titled “What lint Checks”The lint command verifies:
- Coverage: All routes have corresponding screen.meta.ts files
- Orphans: Screens without entry points (warnings)
- Minimum Coverage: Meets the threshold in progressive mode
GitHub Actions Example
Section titled “GitHub Actions Example”name: CI
on: push: branches: [main] pull_request: branches: [main]
jobs: lint: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4 with: node-version: "22" cache: "pnpm"
- name: Install dependencies run: pnpm install
- name: Lint Screenbook run: pnpm screenbook lintExit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | All checks passed |
| 1 | Coverage below threshold or missing metadata |
Full CI Workflow
Section titled “Full CI Workflow”A complete Screenbook CI workflow might include:
name: Screenbook CI
on: push: branches: [main] pull_request: branches: [main]
jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # For PR impact analysis
- uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: node-version: "22" cache: "pnpm"
- run: pnpm install
# Build screen metadata - name: Build Screenbook run: pnpm screenbook build --strict
# Check coverage - name: Lint Screenbook run: pnpm screenbook lint
# PR impact analysis - name: PR Impact if: github.event_name == 'pull_request' run: | pnpm screenbook pr-impact --format markdown >> $GITHUB_STEP_SUMMARYPre-commit Hook
Section titled “Pre-commit Hook”Catch issues before pushing with a pre-commit hook:
#!/bin/shnpx screenbook lintOr with lint-staged:
{ "lint-staged": { "src/**/screen.meta.ts": ["screenbook build --strict"] }}Coverage Badge
Section titled “Coverage Badge”Add a coverage badge to your README:
# In your CI workflow- name: Update Coverage Badge run: | COVERAGE=$(cat .screenbook/coverage.json | jq '.percentage') # Update badge using shields.io or similarStrict Mode
Section titled “Strict Mode”Use --strict to fail on invalid screen references:
- name: Build with Strict Mode run: pnpm screenbook build --strictThis catches:
- Invalid screen IDs in
nextorentryPoints - Typos in screen references
- References to deleted screens
Progressive Mode CI
Section titled “Progressive Mode CI”With progressive adoption, lint checks your included patterns:
adoption: { mode: "progressive", includePatterns: ["src/pages/billing/**"], minimumCoverage: 80,}CI will pass if:
- 80% of routes in
src/pages/billing/**have screen.meta.ts
Troubleshooting
Section titled “Troubleshooting””No routesPattern configured”
Section titled “”No routesPattern configured””The lint command requires routesPattern to find route files:
export default defineConfig({ routesPattern: "src/pages/**/page.tsx", // Add this})“Coverage below threshold”
Section titled ““Coverage below threshold””Options:
- Add missing screen.meta.ts files
- Use
screenbook generateto create skeletons - Lower the
minimumCoveragethreshold temporarily - Adjust
includePatternsto exclude incomplete areas
Orphan Warnings
Section titled “Orphan Warnings”Orphan warnings don’t fail the build but indicate unreachable screens:
⚠ Orphan screens detected: - admin.debug (not reachable from any screen)Fix by:
- Adding the screen to another screen’s
next - Adding
entryPointsto the orphan screen - Removing the orphan if it’s truly unused