Feature Check Quality System
Overview
The Feature Check system automatically ensures that new features added to the codebase have corresponding tests and documentation. This quality check runs in CI/CD pipelines and can be run locally to catch missing tests or documentation early in the development process.
How It Works
Feature Detection
The system detects new features by analyzing git changes:
- New files: Any new JavaScript/TypeScript files in
scripts/,src/,lib/directories - Significant changes: Existing files with more than 50 lines added
- Excluded: Test files, documentation files, configuration files
Test Coverage Verification
For each detected feature, the system looks for corresponding test files:
test/{feature}.test.jstest/{feature}.unit.test.jstest/{feature}.spec.js- Tests that import or reference the feature
Documentation Verification
Features must be documented in at least one of:
README.md- Main project documentationdocs/directory - Detailed documentation.claude/commands/- Command documentation- File with matching name (e.g.,
scripts/monitor.js→docs/monitor.md)
Usage
Local Testing
# Run feature check manually
npm run feature:check
# Run as part of quality checks
npm run quality:all
# Run before committing
npm run commit:checkCI/CD Integration
The feature check runs automatically in GitHub Actions:
- On push to main/develop branches
- On pull requests
- Can be triggered manually
Bypass Options
Skip for Non-Feature Changes
The check automatically skips when changes are:
- Test files only
- Documentation only
- Configuration files only
Manual Skip
# Skip feature check for special cases
node scripts/feature-check.js --skip-feature-checkIgnore Patterns
Create a .featurecheckignore file to exclude specific patterns:
scripts/experimental-*.js
lib/vendor/*
*.generated.jsError Messages
When features lack tests or documentation, you'll see clear error messages:
❌ Feature Check Failed
New features must have tests and documentation:
❌ Feature missing test coverage: scripts/new-analyzer.js
❌ Feature missing documentation: scripts/new-analyzer.js
To fix:
1. Add test files for new features in test/
2. Update documentation in README.md or docs/
3. Or use --skip-feature-check if this is not a featureExamples
Valid Feature Addition
# 1. Add new feature
echo "module.exports = { analyze: () => {} }" > scripts/analyzer.js
# 2. Add test
echo "const analyzer = require('../scripts/analyzer');" > test/analyzer.test.js
# 3. Add documentation
echo "## Analyzer\nAnalyzes code quality..." >> README.md
# 4. Check passes
npm run feature:check
✅ Feature check passed - all features have tests and docsFixing Missing Tests
# Feature without test
git add scripts/reporter.js
# Check fails
npm run feature:check
❌ Feature missing test coverage: scripts/reporter.js
# Add test
cat > test/reporter.test.js << EOF
const { describe, it } = require('node:test');
const reporter = require('../scripts/reporter');
describe('Reporter', () => {
it('should generate reports', () => {
// Test implementation
});
});
EOF
# Now check passes
npm run feature:check
✅ Feature check passedConfiguration
Thresholds
- New file threshold: Any new code file is considered a feature
- Modification threshold: 50+ lines added to existing file
- Test patterns:
.test.js,.spec.js,.unit.test.js - Doc locations: README.md, docs/, .claude/commands/
Environment Variables
GITHUB_BASE_REF: Base branch for comparison in PRs (auto-set by GitHub Actions)SKIP_FEATURE_CHECK: Set to skip checks entirely
Integration with Development Workflow
TDD Workflow
- Write failing test first (TDD RED)
- Implement feature (TDD GREEN)
- Documentation already required - no additional step
- Feature check passes automatically
Regular Development
- Implement feature
- Run
npm run feature:checklocally - Add missing tests/docs if needed
- Commit with confidence
Troubleshooting
False Positives
If the system incorrectly identifies a file as a feature:
- Check if it matches exclusion patterns
- Add to
.featurecheckignoreif needed - Use
--skip-feature-checkfor one-off cases
Missing Detection
If a feature isn't detected:
- Ensure file has correct extension (.js, .ts, etc.)
- Check that changes meet threshold (50+ lines for modifications)
- Verify file isn't in excluded directory
Test Not Found
If tests exist but aren't detected:
- Follow naming convention:
{feature}.test.js - Place tests in
test/directory - Ensure test file imports the feature
Documentation Not Found
If documentation exists but isn't detected:
- Include feature name in documentation
- Use recognizable variants (kebab-case, snake_case)
- Add to README.md for guaranteed detection
Benefits
- Quality Assurance: Ensures all features are tested
- Documentation: Maintains up-to-date documentation
- Early Detection: Catches issues before merge
- Developer Friendly: Clear messages and bypass options
- Automated: No manual review needed
Related Commands
npm run test- Run all testsnpm run docs- Update documentationnpm run quality:all- Run all quality checksnpm run commit:check- Pre-commit validation