Claude-skill-registry build-standards
Build quality standards, validation checkpoints, and compilation requirements
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/build-standards" ~/.claude/skills/majiayu000-claude-skill-registry-build-standards && rm -rf "$T"
skills/data/build-standards/SKILL.mdBuild and Quality Rules
🚨 CRITICAL RULES (Immediate Failure)
1. Build Must Pass
MUST exit with code 0npm run build- Build failures STOP all work immediately
- Fix ALL compilation errors before proceeding
- No implementation with broken build
2. Lint Compliance
MUST pass without errorsnpm run lint- Lint failures require immediate fix
- No proceeding with lint errors
3. Clean Git State for Updates
- NO uncommitted changes before starting updates
- Git status must be clean
- User must commit or stash before proceeding
🟡 STANDARD RULES
Mandatory Build Gate Checkpoints
Build MUST pass with exit code 0 after EACH of these steps:
-
Pre-Implementation Validation (MANDATORY)
- Add
to tsconfig.json"skipLibCheck": true - Run
- MUST exit with code 0npm run build - Fix ALL compilation errors before proceeding
- Add
-
Post-Dependency Install
- After
for new dependenciesnpm install - Verify build still passes
- After
-
Post-HTTP Client Creation
- After creating
src/{ServiceName}Client.ts - Build must pass before continuing
- After creating
-
Post-Mappers Creation
- After creating
src/Mappers.ts - Build must pass before continuing
- After creating
-
Post-Producer Implementation (Each)
- After EACH producer implementation
- Build must pass after every producer
-
Post-Connector Implementation
- After main connector class
- Build must pass before continuing
-
Post-Entry Point Update
- After updating
src/index.ts - Build must pass before continuing
- After updating
-
FINAL BUILD GATE (Task Completion)
- ABSOLUTE REQUIREMENT:
exits with code 0npm run build - Task CANNOT be completed if build fails
- Zero TypeScript warnings allowed
- Zero compilation errors allowed
- ABSOLUTE REQUIREMENT:
CRITICAL: If
npm run build fails at ANY checkpoint, STOP all work immediately.
TypeScript Configuration
{ "compilerOptions": { "skipLibCheck": true, // MANDATORY - Add before implementation "strict": true, // Maintain strict checking "noImplicitAny": true, "strictNullChecks": true } }
Package.json Scripts
Required scripts that must exist and work:
: Compile TypeScriptbuild
: Remove build artifactsclean
: Check code stylelint
: Run unit teststest
: Run integration teststest:integration
Dependency Installation
- Install exact versions when specified
- Run
after adding dependenciesnpm install - Verify no peer dependency warnings
- Check for security vulnerabilities
Code Generation Rules
- NEVER modify files in
directorygenerated/ - Generated files are read-only
- Failed generation triggers API spec fix
- Regenerate after any API spec changes
🟢 GUIDELINES
Performance Considerations
- Avoid synchronous file operations
- Use async/await properly
- Implement appropriate timeouts
- Handle large datasets efficiently
Memory Management
- Clean up resources in disconnect methods
- Avoid memory leaks in long-running operations
- Use streaming for large responses when possible
Error Recovery
- Implement proper cleanup on errors
- Don't leave partial state
- Log errors appropriately
- Provide meaningful error messages
Code Quality Metrics
- Maintain consistent code style
- Follow existing patterns
- Keep functions focused and small
- Avoid deep nesting
Validation Sequence
# Standard validation sequence npm run clean npm run build npm run lint npm run test npm run test:integration # If credentials available
📝 EXCEPTIONS LOG
When Build Can Fail Temporarily
- During iterative development (but must fix before commit)
- When updating dependencies (fix immediately after)
- Never leave build broken between tasks
Lint Exception Handling
- Use inline disable comments sparingly
- Document reason for disabling:
// eslint-disable-next-line @typescript-eslint/no-explicit-any // Reason: External API returns untyped response
Type Generation Validation (Gate 2)
Step 1: Run Generation
# Clean previous generation rm -rf generated/ # Run generator npm run clean && npm run generate # Capture exit code EXIT_CODE=$? echo "Exit code: $EXIT_CODE" # Exit code MUST be 0 if [ $EXIT_CODE -ne 0 ]; then echo "❌ Gate 2 FAILED: Generation failed" exit 1 fi
Step 2: Validate Generated Files
# Check generated directory exists if [ ! -d "generated" ]; then echo "❌ Gate 2 FAILED: No generated directory" exit 1 fi # List generated files ls -la generated/api/ ls -la generated/model/ # Count generated files FILE_COUNT=$(find generated -name "*.ts" | wc -l) echo "Generated $FILE_COUNT TypeScript files" # Must have at least some files if [ $FILE_COUNT -eq 0 ]; then echo "❌ Gate 2 FAILED: No files generated" exit 1 fi
Step 3: Check for InlineResponse Types
# InlineResponse indicates inline schemas (bad) if grep -r "InlineResponse\|InlineRequestBody" generated/; then echo "❌ Gate 2 FAILED: Inline types found" echo "Fix: Move inline schemas to components/schemas in api.yml" exit 1 fi
Why this matters: InlineResponse types indicate inline schemas in api.yml. All schemas must be named and in components/schemas.
Step 4: Validate TypeScript Compilation After Generation
# Try to compile generated code npm run build # Check exit code if [ $? -ne 0 ]; then echo "❌ Gate 2 FAILED: TypeScript compilation errors" echo "Check generated types for issues" exit 1 fi
Build Validation (Gate 6)
Step 1: Clean Build
# Clean previous build rm -rf dist/ # Run build npm run build # Capture exit code EXIT_CODE=$? echo "Build exit code: $EXIT_CODE" # MUST be 0 if [ $EXIT_CODE -ne 0 ]; then echo "❌ Gate 6 FAILED: Build failed" exit 1 fi
Step 2: Validate Artifacts
# Distribution directory must exist if [ ! -d "dist" ]; then echo "❌ Gate 6 FAILED: No dist directory" exit 1 fi # Count artifacts FILE_COUNT=$(find dist -name "*.js" | wc -l) echo "Generated $FILE_COUNT JavaScript files" # Must have files if [ $FILE_COUNT -eq 0 ]; then echo "❌ Gate 6 FAILED: No compiled files" exit 1 fi # Check for index files if [ ! -f "dist/index.js" ]; then echo "❌ Gate 6 FAILED: No dist/index.js" exit 1 fi
Step 3: Dependency Locking
# Run shrinkwrap npm run shrinkwrap # Capture exit code EXIT_CODE=$? echo "Shrinkwrap exit code: $EXIT_CODE" # MUST be 0 if [ $EXIT_CODE -ne 0 ]; then echo "❌ Gate 6 FAILED: Shrinkwrap failed" exit 1 fi # Verify shrinkwrap file exists if [ ! -f "npm-shrinkwrap.json" ]; then echo "❌ Gate 6 FAILED: npm-shrinkwrap.json not created" exit 1 fi
Step 4: Type Check (if separate)
# Run type check separately if configured npm run type-check 2>&1 # Should show no errors if [ $? -ne 0 ]; then echo "⚠️ Type check failed" fi
Common Build Failures & Fixes
Failure: TypeScript Errors
Error: Property 'x' does not exist on type 'Y'
Fix: Check type definitions
- Ensure using generated types
- Verify mapper returns correct type
- Check method signatures
Failure: Missing Imports
Error: Cannot find module 'X'
Fix: Check imports
- Verify relative paths correct
- Ensure generated types imported
- Check package dependencies
Failure: Shrinkwrap Failed
Error: npm ERR! shrinkwrap failed
Fix: Check npm state
- Ensure node_modules clean
- Run npm install
- Retry shrinkwrap
Failure: InlineResponse Types
Error: Found InlineResponse200, InlineResponse201
Cause: Inline schema in api.yml
# ❌ WRONG - Inline schema responses: '200': content: application/json: schema: type: object # Inline schema properties: ...
Fix: Move to components/schemas
# ✅ CORRECT - Reference named schema responses: '200': content: application/json: schema: $ref: '#/components/schemas/Webhook'
Failure: Generation Error
Error: "Could not resolve reference"
Cause: Invalid $ref in api.yml
# ❌ WRONG $ref: '#/components/schemas/NonExistent'
Fix: Ensure referenced schema exists
# ✅ CORRECT components: schemas: NonExistent: type: object
Gate Validation Criteria
Gate 2 Criteria (Type Generation) - MUST ALL PASS
-
exit code is 0npm run clean && npm run generate - Generated directory exists with TypeScript files
- No InlineResponse or InlineRequestBody types
- At least one API interface generated
- At least one model type generated
-
succeeds with no errorsnpm run build - Generated types match API specification
Gate 6 Criteria (Final Build) - MUST ALL PASS
-
exit code is 0npm run build - No TypeScript compilation errors
- No linting errors
- dist/ directory created
- JavaScript files in dist/
- Type declaration files (.d.ts) in dist/
-
exit code is 0npm run shrinkwrap - npm-shrinkwrap.json file exists
- All imports resolve correctly
All criteria MUST pass to proceed/complete task