Progressive Adoption
Screenbook supports progressive adoption, allowing you to introduce screen metadata gradually without requiring 100% coverage from day one.
The Challenge
Section titled “The Challenge”Large codebases may have hundreds of routes. Requiring screen.meta.ts for every route immediately is impractical. Progressive adoption lets you:
- Start with one team or feature area
- Expand coverage incrementally
- Set and track coverage goals
Configuration
Section titled “Configuration”Enable progressive mode in screenbook.config.ts:
import { defineConfig } from "screenbook"
export default defineConfig({ metaPattern: "src/**/screen.meta.ts", routesPattern: "src/pages/**/page.tsx",
adoption: { // Enable progressive mode mode: "progressive",
// Only check these areas for coverage includePatterns: [ "src/pages/billing/**", "src/pages/payments/**", ],
// Minimum coverage required to pass lint minimumCoverage: 80, },})How It Works
Section titled “How It Works”Full Mode (Default)
Section titled “Full Mode (Default)”adoption: { mode: "full"}- All routes matching
routesPatternmust have screen.meta.ts lintfails if any route is missing metadata- Suitable for new projects or full adoption
Progressive Mode
Section titled “Progressive Mode”adoption: { mode: "progressive", includePatterns: ["src/pages/billing/**"], minimumCoverage: 80,}- Only routes matching
includePatternsare checked - Coverage is calculated within the included patterns
lintpasses if coverage meetsminimumCoverage
Adoption Strategy
Section titled “Adoption Strategy”Phase 1: Pilot Team
Section titled “Phase 1: Pilot Team”Start with one team or feature area:
adoption: { mode: "progressive", includePatterns: ["src/pages/billing/**"], minimumCoverage: 50,}Phase 2: Expand Coverage
Section titled “Phase 2: Expand Coverage”Add more areas and increase the threshold:
adoption: { mode: "progressive", includePatterns: [ "src/pages/billing/**", "src/pages/payments/**", "src/pages/settings/**", ], minimumCoverage: 70,}Phase 3: Full Adoption
Section titled “Phase 3: Full Adoption”When ready, switch to full mode:
adoption: { mode: "full",}Monitoring Progress
Section titled “Monitoring Progress”Coverage Report
Section titled “Coverage Report”Run screenbook build to see coverage:
npx screenbook buildOutput:
Coverage: 12/15 (80%)
Missing screen.meta.ts: - src/pages/billing/archive/page.tsx - src/pages/billing/export/page.tsx - src/pages/billing/settings/page.tsxcoverage.json
Section titled “coverage.json”The build also generates .screenbook/coverage.json:
{ "total": 15, "covered": 12, "percentage": 80, "missing": [ { "route": "src/pages/billing/archive/page.tsx", "suggestedPath": "src/pages/billing/archive/screen.meta.ts" } ], "byOwner": { "billing-team": { "count": 10, "screens": ["..."] } }, "byTag": { "billing": 10, "settings": 2 }}CI Integration
Section titled “CI Integration”Use coverage data in CI:
- name: Check Coverage run: | npx screenbook lint # Exits with code 1 if below minimumCoverageAuto-generating Metadata
Section titled “Auto-generating Metadata”Speed up adoption with auto-generation:
# Preview what would be generatednpx screenbook generate --dry-run
# Generate missing screen.meta.ts filesnpx screenbook generateThis creates skeleton files that you can customize:
// Auto-generatedexport const screen = defineScreen({ id: "billing.archive", title: "Archive", route: "/billing/archive",})Team Workflow
Section titled “Team Workflow”1. Set Adoption Goals
Section titled “1. Set Adoption Goals”Define coverage milestones:
| Phase | Coverage | Timeline |
|---|---|---|
| Pilot | 50% | Sprint 1 |
| Expand | 70% | Sprint 2-3 |
| Full | 100% | Sprint 4+ |
2. Track Progress
Section titled “2. Track Progress”Add coverage to team dashboards:
# Extract coverage percentagecat .screenbook/coverage.json | jq '.percentage'3. Celebrate Milestones
Section titled “3. Celebrate Milestones”When reaching 100% coverage:
adoption: { mode: "full", // No more partial coverage!}- Start small - Pick the area you know best
- Use generate - Auto-generate skeletons, then customize
- Set realistic goals - 80% is a good intermediate target
- Make it visible - Share coverage metrics with the team
- Iterate - Adjust patterns and thresholds as you learn