| name | confidence-check-skills |
| description | Pre-implementation validation framework requiring ≥90% confidence before coding. Prevents wrong-direction work by assessing duplicates, architecture alignment, documentation, OSS references, and root cause understanding. Use before implementing features, fixes, or refactoring to save 5K-50K tokens per prevented error. |
| license | MIT |
Confidence Check Skills
Purpose: Quantified pre-implementation validation system that prevents wasted effort by requiring ≥90% confidence before coding begins.
Critical Use Case: Spend 100-200 tokens on validation to save 5,000-50,000 tokens on wrong-direction work. Proven results: 100% precision/recall in production testing.
Used By: All agents before implementation - especially implementor, developer-agent, frontend-ui-developer, ml-model-implementor
When to Use Confidence Check
MANDATORY before:
- ✅ Implementing new features or functionality
- ✅ Major refactoring or architectural changes
- ✅ Bug fixes (except critical production emergencies)
- ✅ Adding new libraries, frameworks, or dependencies
- ✅ Database schema changes
- ✅ API endpoint creation
- ✅ Authentication/security implementations
OPTIONAL/SKIP for:
- ❌ Trivial documentation updates
- ❌ Simple typo fixes
- ❌ Critical production hotfixes (time-sensitive)
- ❌ Exploratory research (no code changes)
The 5-Factor Assessment Model
Overview
Each factor contributes a weighted score to calculate overall confidence:
| Factor | Weight | Purpose | Tools Used |
|---|
| Duplicate Detection | 25% | Prevent re-implementing existing solutions | Glob, Grep, ChromaDB |
| Architecture Alignment | 25% | Verify tech stack compatibility | Read, Grep |
| Documentation Review | 20% | Ensure official docs consulted | Glob, Read |
| OSS Reference | 15% | Find proven working implementations | WebSearch |
| Root Cause Analysis | 15% | Verify problem understanding | Read, analysis |
Formula:
confidence = (duplicate × 0.25) + (architecture × 0.25) + (docs × 0.20)
+ (oss × 0.15) + (rootcause × 0.15)
Result: 0.0 to 1.0 (0% to 100%)
Factor 1: Duplicate Detection (25%)
Question: Does this functionality already exist in the codebase?
Automated Checks
const similarFiles = Glob({
pattern: `**/*${featureKeyword}*{.ts,.js,.py,.rs,.md}`,
path: "."
});
const similarCode = Grep({
pattern: coreLogicPattern,
glob: "**/*.{ts,js,py,rs}",
output_mode: "files_with_matches"
});
const semanticMatches = mcp__chroma__query_documents({
collection_name: "codebase_features_all",
query_texts: [featureDescription],
n_results: 5,
where: { "status": "implemented" }
});
let duplicateScore = 1.0;
if (similarFiles.length > 0) {
duplicateScore = 0.0;
} else if (similarCode.length > 0) {
duplicateScore = 0.5;
} else if (semanticMatches.distances[0][0] < 0.3) {
duplicateScore = 0.3;
}
return duplicateScore;
Pass Criteria
- ✅ PASS (1.0): No similar files, code, or semantic matches
- ⚠️ PARTIAL (0.5): Similar code patterns but different purpose
- ⚠️ PARTIAL (0.3): Semantic similarity but different implementation
- ❌ FAIL (0.0): Duplicate functionality already exists
Example Scenarios
Scenario 1: JWT Authentication
Feature: "Implement JWT authentication middleware"
Checks:
- Glob: **/*auth*.{ts,js} → Found: src/auth/jwt-middleware.ts ❌
- Grep: "function.*authenticate|jwt.*verify" → 3 matches ❌
- ChromaDB: "jwt authentication" → Distance 0.08 (highly similar) ❌
Score: 0.0 (FAIL - duplicate exists)
Recommendation: Use existing src/auth/jwt-middleware.ts
Scenario 2: Rate Limiter
Feature: "Create API rate limiter"
Checks:
- Glob: **/*rate*limit*.{ts,js} → None found ✅
- Grep: "rateLimit|rate.*limit" → None found ✅
- ChromaDB: "rate limiting middleware" → Distance 0.82 (dissimilar) ✅
Score: 1.0 (PASS - no duplicates)
Recommendation: Proceed with implementation
Factor 2: Architecture Alignment (25%)
Question: Is this compatible with the current tech stack and patterns?
Automated Checks
const claudeMd = Read({ file_path: "CLAUDE.md" });
const readmeMd = Read({ file_path: "README.md" });
const packageJson = Read({ file_path: "package.json" });
const cargoToml = Read({ file_path: "Cargo.toml" });
const requirementsTxt = Read({ file_path: "requirements.txt" });
const techStack = {
language: detectLanguage([packageJson, cargoToml, requirementsTxt]),
frameworks: extractFrameworks(claudeMd, packageJson),
patterns: extractPatterns(claudeMd, readmeMd),
database: detectDatabase(claudeMd, packageJson)
};
let architectureScore = 1.0;
if (proposedTech.language !== techStack.language) {
architectureScore = 0.0;
} else if (!techStack.frameworks.includes(proposedTech.framework)) {
architectureScore = 0.5;
} else if (violatesPatterns(proposedTech, techStack.patterns)) {
architectureScore = 0.3;
}
return architectureScore;
Pass Criteria
- ✅ PASS (1.0): Fully compatible with documented tech stack
- ⚠️ PARTIAL (0.5): Compatible but introduces new framework/library
- ⚠️ PARTIAL (0.3): Compatible but violates documented patterns
- ❌ FAIL (0.0): Incompatible (wrong language, framework, database)
Example Scenarios
Scenario 1: Python Library in Rust Project
Proposal: "Add pandas for data processing"
Tech Stack: Rust (from Cargo.toml)
Check:
- Cargo.toml exists → Rust project ✅
- Proposed: Python pandas library ❌
Score: 0.0 (FAIL - language mismatch)
Recommendation: Use Rust polars crate instead
Scenario 2: New Framework Addition
Proposal: "Use Tailwind CSS for styling"
Tech Stack: React + plain CSS (from package.json)
Check:
- package.json shows React ✅
- Currently using plain CSS (no Tailwind) ⚠️
- CLAUDE.md doesn't prohibit Tailwind ✅
Score: 0.5 (PARTIAL - new framework, acceptable)
Recommendation: Proceed, but document Tailwind addition
Factor 3: Documentation Review (20%)
Question: Have relevant documentation and guides been consulted?
Automated Checks
const docsFound = Glob({
pattern: "**/{docs,documentation,README,CLAUDE}*.md",
path: "."
});
const relevantDocs = [];
for (const docFile of docsFound) {
const content = Read({ file_path: docFile });
if (content.toLowerCase().includes(featureKeyword.toLowerCase())) {
relevantDocs.push({
file: docFile,
excerpts: extractRelevantSections(content, featureKeyword)
});
}
}
let docsScore = 0.0;
if (relevantDocs.length === 0) {
docsScore = 0.0;
} else if (relevantDocs.length >= 1) {
docsScore = 1.0;
}
if (docsFound.length === 0) {
docsScore = 0.5;
}
return docsScore;
Pass Criteria
- ✅ PASS (1.0): Relevant documentation found and reviewed
- ⚠️ PARTIAL (0.5): No documentation exists in project (not agent's fault)
- ❌ FAIL (0.0): Documentation exists but not consulted
Example Scenarios
Scenario 1: Documented Authentication Pattern
Feature: "Implement OAuth2 flow"
Check:
- Glob: **/docs/**/*.md → Found: docs/authentication-guide.md ✅
- Read: docs/authentication-guide.md → Contains "OAuth2" section ✅
- Reviewed: Yes (agent read the OAuth2 section) ✅
Score: 1.0 (PASS - docs found and reviewed)
Recommendation: Follow documented OAuth2 pattern
Scenario 2: No Documentation
Feature: "Create data export feature"
Check:
- Glob: **/docs/**/*.md → None found ⚠️
- Glob: **/README.md → Found but no mention of data export ⚠️
Score: 0.5 (PARTIAL - no docs exist)
Recommendation: Proceed, but create docs after implementation
Factor 4: OSS Reference (15%)
Question: Is there a proven, working implementation we can reference?
Automated Checks
const githubSearch = WebSearch({
query: `${techStack} ${featureName} implementation site:github.com`,
allowed_domains: ["github.com"]
});
const npmSearch = WebSearch({
query: `${featureName} site:npmjs.com`,
allowed_domains: ["npmjs.com"]
});
const cratesSearch = WebSearch({
query: `${featureName} site:crates.io`,
allowed_domains: ["crates.io"]
});
const references = parseSearchResults(githubSearch, npmSearch, cratesSearch);
let ossScore = 0.0;
if (references.some(ref => ref.stars >= 1000 && ref.maintained)) {
ossScore = 1.0;
} else if (references.some(ref => ref.stars >= 100)) {
ossScore = 0.7;
} else if (references.length > 0) {
ossScore = 0.4;
}
return ossScore;
Pass Criteria
- ✅ PASS (1.0): High-quality reference (1K+ stars, actively maintained)
- ⚠️ PARTIAL (0.7): Medium-quality reference (100+ stars)
- ⚠️ PARTIAL (0.4): Low-quality reference (exists but unverified)
- ❌ FAIL (0.0): No working implementation found
Example Scenarios
Scenario 1: Express.js Rate Limiting
Feature: "API rate limiter for Express"
Tech Stack: Node.js + Express
WebSearch: "express rate limiting npm"
Results:
- express-rate-limit: 3.2K stars, maintained ✅
- rate-limiter-flexible: 2.8K stars, maintained ✅
Score: 1.0 (PASS - multiple high-quality references)
Recommendation: Use express-rate-limit (most popular)
Scenario 2: Custom Algorithm
Feature: "Implement custom sorting algorithm for trades"
WebSearch: "custom trade sorting algorithm"
Results:
- No high-quality libraries found ❌
- Academic papers exist (not production code) ⚠️
Score: 0.0 (FAIL - no proven implementation)
Recommendation: Implement custom, but add extensive tests
Factor 5: Root Cause Analysis (15%)
Question: Is the underlying problem clearly understood?
Manual Evaluation
This check requires human judgment but follows a structured approach:
const problemDescription = extractProblemFromRequest(userRequest);
const clarityChecks = {
symptomsDescribed: problemDescription.includes("error") ||
problemDescription.includes("fails") ||
problemDescription.includes("doesn't work"),
rootCauseIdentified: problemDescription.includes("because") ||
problemDescription.includes("due to") ||
problemDescription.includes("caused by"),
reproductionSteps: problemDescription.match(/\d+\.\s+/g)?.length >= 2,
expectedVsActual: problemDescription.includes("expected") &&
problemDescription.includes("actual"),
contextProvided: problemDescription.length > 100
};