Skip to content

About

Triple AI validation skill for OpenSpec (Claude + Gemini)

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

OpenSpec Triple AI Skill

Adaptive Triple AI validation for OpenSpec proposals and code implementation.

Claude Code OpenSpec License: MIT

Overview

This skill adds Triple AI validation to OpenSpec workflows, combining Claude's decision-making with Gemini's technical review and creative challenge capabilities.

┌─────────────────────────────────────────────────────────┐
│                 TRIPLE AI ARCHITECTURE                  │
├─────────────────────────────────────────────────────────┤
│                                                         │
│   ┌─────────────┐                                       │
│   │   CLAUDE    │  60% - Author + Final Decision        │
│   │ (Orchestrator)                                      │
│   └──────┬──────┘                                       │
│          │                                              │
│    ┌─────┴─────┐                                        │
│    ▼           ▼                                        │
│ ┌──────┐   ┌──────────┐                                 │
│ │Gemini│   │  Gemini  │  20% each                       │
│ │Review│   │Challenger│  (or Validator in Apply)        │
│ └──────┘   └──────────┘                                 │
│                                                         │
└─────────────────────────────────────────────────────────┘

Features

Confidence-Based Routing

Not every task needs full validation. The skill intelligently routes based on complexity:

Confidence Route When Used
HIGH (90%+) Claude Only Standard patterns, proven solutions
MEDIUM (60-89%) + Reviewer New patterns, needs validation
LOW (<60%) Full Triple AI Complex, uncertain, multiple approaches

Two Workflow Loops

Proposal Loop (Design Review)

10-step workflow for validating proposals before implementation:

  • Creates proposal.md, design.md, tasks.md
  • Validates Clean Architecture compliance
  • Ensures TDD strategy completeness
  • Gemini Challenger proposes alternatives with conviction scores

Apply Loop (Code Implementation)

9-step workflow for validated code implementation:

  • Layer-based parallel execution (Domain → App → Infra+UI)
  • TDD enforcement (RED → GREEN → REFACTOR)
  • Deviation detection and handling
  • Quality gates at each phase

Production-Grade Principles

  • Clean Architecture: 4-layer separation with inward dependencies
  • TDD First: Tests before implementation, coverage targets per layer
  • Parallel Execution: Work distributed by architectural layer
  • Highest Standards: No shortcuts, production-quality code

Installation

1. Copy to your project

# Clone this repo
git clone https://github.com/YOUR_USERNAME/openspec-triple-ai-skill.git

# Copy skill to your project
cp -r openspec-triple-ai-skill/gemini-claude-loop YOUR_PROJECT/.claude/skills/

2. Set environment variable

# Add to your shell profile (.bashrc, .zshrc, etc.)
export GEMINI_API_KEY="your-api-key-here"

Get your API key from Google AI Studio.

3. (Optional) Add to CLAUDE.md

# CLAUDE.md

When "skill" keyword is mentioned during openspec work:
- Use gemini-claude-loop for Triple AI validation
- Follow PROPOSAL_LOOP.md for proposals
- Follow APPLY_LOOP.md for implementation

Usage

Proposal with Triple AI

openspec proposal skill

or in conversation:

"Create a proposal for user authentication feature using skill"

Apply with Triple AI

openspec apply skill

or in conversation:

"Apply the approved proposal using skill"

Workflow Diagrams

Proposal Loop (10 Steps)

Design review workflow with confidence-based AI routing.

┌─────────────────────────────────────────────────────────────────────────────┐
│                         PROPOSAL LOOP WORKFLOW                              │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 1: CREATE DOCUMENTS                                            │    │
│  │ ┌──────────────┐  ┌──────────────┐  ┌──────────────┐                │    │
│  │ │ proposal.md  │  │  design.md   │  │  tasks.md    │                │    │
│  │ │ What & Why   │  │ Architecture │  │ TDD Tasks    │                │    │
│  │ └──────────────┘  └──────────────┘  └──────────────┘                │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 2: CONFIDENCE ASSESSMENT                                       │    │
│  │                                                                     │    │
│  │   Claude evaluates complexity and determines routing:               │    │
│  │   ┌─────────────────────────────────────────────────┐               │    │
│  │   │  Per-Section Analysis → Overall Score (0-100%)  │               │    │
│  │   └─────────────────────────────────────────────────┘               │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│            ┌───────────────────────┼───────────────────────┐                │
│            │                       │                       │                │
│            ▼                       ▼                       ▼                │
│  ┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐          │
│  │  HIGH (90%+)     │  │  MEDIUM (60-89%) │  │   LOW (<60%)     │          │
│  │  ══════════════  │  │  ══════════════  │  │  ══════════════  │          │
│  │                  │  │                  │  │                  │          │
│  │  Claude Only     │  │  Claude          │  │  Claude          │          │
│  │  ┌────────────┐  │  │  ┌────────────┐  │  │  ┌────────────┐  │          │
│  │  │  Claude    │  │  │  │  Claude    │  │  │  │  Claude    │  │          │
│  │  │  (100%)    │  │  │  │   (60%)    │  │  │  │   (60%)    │  │          │
│  │  └────────────┘  │  │  └─────┬──────┘  │  │  └─────┬──────┘  │          │
│  │                  │  │        │         │  │        │         │          │
│  │                  │  │        ▼         │  │   ┌────┴────┐    │          │
│  │                  │  │  ┌──────────┐    │  │   ▼         ▼    │          │
│  │                  │  │  │ Reviewer │    │  │ ┌────────┐ ┌─────────┐      │
│  │                  │  │  │  (20%)   │    │  │ │Reviewer│ │Challenger│     │
│  │                  │  │  └──────────┘    │  │ │ (20%)  │ │  (20%)  │      │
│  │                  │  │                  │  │ └────────┘ └─────────┘      │
│  │                  │  │                  │  │      Parallel Run           │
│  │  ───── FAST ────▶│  │                  │  │                  │          │
│  └────────┬─────────┘  └────────┬─────────┘  └────────┬─────────┘          │
│           │                     │                     │                    │
│           │              ┌──────┴──────┐       ┌──────┴──────┐             │
│           │              ▼             │       ▼             │             │
│           │    ┌─────────────────┐     │  ┌─────────────────┐│             │
│           │    │ STEP 4: SYNTH   │     │  │ STEP 4: SYNTH   ││             │
│           │    │ Compare Results │     │  │ + Conviction    ││             │
│           │    └────────┬────────┘     │  └────────┬────────┘│             │
│           │             │              │           │         │             │
│           │             ▼              │           ▼         │             │
│           │    ┌─────────────────┐     │  ┌─────────────────┐│             │
│           │    │ STEP 5: VALIDATE│     │  │ STEP 5: VALIDATE││             │
│           │    │ Accept/Modify/  │     │  │ High Conviction ││             │
│           │    │ Skip Feedback   │     │  │ (8+) = MUST FIX ││             │
│           │    └────────┬────────┘     │  └────────┬────────┘│             │
│           │             │              │           │         │             │
│           │             ▼              │           ▼         │             │
│           │    ┌─────────────────┐     │  ┌─────────────────┐│             │
│           │    │ STEP 6: REVISE  │     │  │ STEP 6: REVISE  ││             │
│           │    │ Update Docs     │     │  │ Update Docs     ││             │
│           │    └────────┬────────┘     │  └────────┬────────┘│             │
│           │             │              │           │         │             │
│           │             ▼              │           ▼         │             │
│           │    ┌─────────────────┐     │  ┌─────────────────┐│             │
│           │    │ STEP 7: RE-REV? │     │  │ STEP 7: RE-REV? ││             │
│           │    │ Critical Issue? │     │  │ Max 3 iterations││             │
│           │    │ ─► Loop Back    │     │  │ ─► Loop Back    ││             │
│           │    └────────┬────────┘     │  └────────┬────────┘│             │
│           │             │              │           │         │             │
│           └─────────────┴──────────────┴───────────┴─────────┘             │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 8: LGTM                                                        │    │
│  │ ┌─────────────────────────────────────────────────────────────┐     │    │
│  │ │  "I validated and confirm LGTM" - Claude (ONLY decision maker)│    │    │
│  │ └─────────────────────────────────────────────────────────────┘     │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 9: CONSISTENCY CHECK                                           │    │
│  │                                                                     │    │
│  │   proposal.md ←→ design.md ←→ tasks.md                              │    │
│  │                                                                     │    │
│  │   MATCH? ─────► Continue                                            │    │
│  │   MISMATCH? ──► User decides which doc is authoritative             │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 10: USER CONFIRMATION                                          │    │
│  │ ┌─────────────────────────────────────────────────────────────┐     │    │
│  │ │              "Apply openspec?" ─► Yes ─► Apply Loop          │    │    │
│  │ └─────────────────────────────────────────────────────────────┘     │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Apply Loop (9 Steps)

Code implementation workflow with TDD and layer-based parallel execution.

┌─────────────────────────────────────────────────────────────────────────────┐
│                          APPLY LOOP WORKFLOW                                │
├─────────────────────────────────────────────────────────────────────────────┤
│                                                                             │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 1: PLAN PHASE                                                  │    │
│  │                                                                     │    │
│  │   Load approved proposal and identify:                              │    │
│  │   • Architectural layers and their tasks                            │    │
│  │   • Dependencies between layers                                     │    │
│  │   • TDD strategy and coverage targets                               │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 2: LAYER DISTRIBUTION                                          │    │
│  │                                                                     │    │
│  │   PHASE 1          PHASE 2              PHASE 3                     │    │
│  │   ════════         ════════             ════════                    │    │
│  │   ┌────────┐       ┌────────────┐       ┌─────────┐  ┌────────┐     │    │
│  │   │ DOMAIN │ ────► │APPLICATION │ ────► │  INFRA  │  │   UI   │     │    │
│  │   │ 90%cov │       │   85%cov   │       │  80%cov │  │ 70%cov │     │    │
│  │   └────────┘       └────────────┘       └─────────┘  └────────┘     │    │
│  │   D-001,D-002        A-001,A-002           I-001        U-001       │    │
│  │   (parallel)        (sequential)       (parallel with UI)          │    │
│  │                                                                     │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 3-6: IMPLEMENT EACH TASK (Repeat per layer)                    │    │
│  │                                                                     │    │
│  │   ┌───────────────────────────────────────────────────────────┐     │    │
│  │   │                    TDD CYCLE (per task)                   │     │    │
│  │   │                                                           │     │    │
│  │   │    ┌─────────┐      ┌─────────┐      ┌──────────┐         │     │    │
│  │   │    │   RED   │ ───► │  GREEN  │ ───► │ REFACTOR │         │     │    │
│  │   │    │         │      │         │      │          │         │     │    │
│  │   │    │ Write   │      │ Minimal │      │ Improve  │         │     │    │
│  │   │    │ Failing │      │ Code to │      │ Quality  │         │     │    │
│  │   │    │ Test    │      │ Pass    │      │          │         │     │    │
│  │   │    └─────────┘      └─────────┘      └──────────┘         │     │    │
│  │   │         │                                   │             │     │    │
│  │   │         ▼                                   ▼             │     │    │
│  │   │    npm test                            npm test           │     │    │
│  │   │    → FAIL ✓                            → PASS ✓           │     │    │
│  │   └───────────────────────────────────────────────────────────┘     │    │
│  │                                    │                                │    │
│  │                                    ▼                                │    │
│  │   ┌───────────────────────────────────────────────────────────┐     │    │
│  │   │                 CONFIDENCE ROUTING                        │     │    │
│  │   │                                                           │     │    │
│  │   │    HIGH (90%+)        MEDIUM           LOW (<60%)         │     │    │
│  │   │        │                │                  │              │     │    │
│  │   │        ▼                ▼                  ▼              │     │    │
│  │   │    Skip Review     ┌─────────┐      ┌─────────────────┐   │     │    │
│  │   │        │           │Reviewer │      │Reviewer+Validator│  │     │    │
│  │   │        │           │Technical│      │   (parallel)     │  │     │    │
│  │   │        │           │  Check  │      │                  │  │     │    │
│  │   │        │           └────┬────┘      └────────┬─────────┘  │     │    │
│  │   │        │                │                    │            │     │    │
│  │   │        └────────────────┴────────────────────┘            │     │    │
│  │   └───────────────────────────────────────────────────────────┘     │    │
│  │                                    │                                │    │
│  │                                    ▼                                │    │
│  │   ┌───────────────────────────────────────────────────────────┐     │    │
│  │   │ STEP 5: DEVIATION HANDLING (if plan mismatch)             │     │    │
│  │   │                                                           │     │    │
│  │   │  MINOR      Auto-approve, update tasks.md                 │     │    │
│  │   │  MODERATE   Claude decides, notify user                   │     │    │
│  │   │  MAJOR      User approval required                        │     │    │
│  │   │  CRITICAL   STOP - User decision blocking                 │     │    │
│  │   └───────────────────────────────────────────────────────────┘     │    │
│  │                                    │                                │    │
│  │                                    ▼                                │    │
│  │   ┌───────────────────────────────────────────────────────────┐     │    │
│  │   │ STEP 6: QUALITY GATE (ALL must pass)                      │     │    │
│  │   │                                                           │     │    │
│  │   │  ┌──────────┐ ┌──────────┐ ┌────────┐ ┌───────┐           │     │    │
│  │   │  │npm test  │ │typecheck │ │  lint  │ │ build │           │     │    │
│  │   │  │  PASS    │ │  PASS    │ │  PASS  │ │ PASS  │           │     │    │
│  │   │  └──────────┘ └──────────┘ └────────┘ └───────┘           │     │    │
│  │   │                                                           │     │    │
│  │   │  FAIL? ─► Fix and repeat Step 3-6                         │     │    │
│  │   └───────────────────────────────────────────────────────────┘     │    │
│  │                                                                     │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 7: PHASE COMPLETE                                              │    │
│  │                                                                     │    │
│  │   ┌──────────────────────────────────────────────────────────┐      │    │
│  │   │  Domain Phase Complete!                                  │      │    │
│  │   │  ├─ D-001: ✓ TDD Complete, 94% coverage                  │      │    │
│  │   │  └─ D-002: ✓ TDD Complete, 91% coverage                  │      │    │
│  │   │                                                          │      │    │
│  │   │  Next: Application Phase ─────────────────────► Loop     │      │    │
│  │   └──────────────────────────────────────────────────────────┘      │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                          (Repeat for all phases)                            │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 8: FINAL LGTM                                                  │    │
│  │                                                                     │    │
│  │   ┌──────────────────────────────────────────────────────────┐      │    │
│  │   │  All Phases Complete:                                    │      │    │
│  │   │  ├─ Phase 1 (Domain):         ✓ COMPLETE                 │      │    │
│  │   │  ├─ Phase 2 (Application):    ✓ COMPLETE                 │      │    │
│  │   │  └─ Phase 3 (Infra + UI):     ✓ COMPLETE                 │      │    │
│  │   │                                                          │      │    │
│  │   │  "I validated and confirm LGTM" - Claude                 │      │    │
│  │   └──────────────────────────────────────────────────────────┘      │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                    │                                        │
│                                    ▼                                        │
│  ┌─────────────────────────────────────────────────────────────────────┐    │
│  │ STEP 9: DOCUMENT SYNC                                               │    │
│  │                                                                     │    │
│  │   Update:                                                           │    │
│  │   • tasks.md    ─► Mark complete, actual coverage                   │    │
│  │   • design.md   ─► Document any deviations                          │    │
│  │   • proposal.md ─► Add implementation notes                         │    │
│  │                                                                     │    │
│  │   ══════════════════════════════════════════════════════            │    │
│  │                    IMPLEMENTATION COMPLETE                          │    │
│  │   ══════════════════════════════════════════════════════            │    │
│  └─────────────────────────────────────────────────────────────────────┘    │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Quick Flow Summary

┌─────────────────────────────────────────────────────────────────────────────┐
│                                                                             │
│   PROPOSAL LOOP (Design)              APPLY LOOP (Code)                     │
│   ══════════════════════              ═════════════════                     │
│                                                                             │
│   1. Create Docs                      1. Plan Layers                        │
│   2. Confidence Check ─┐              2. Distribute Tasks                   │
│      │                 │              3. TDD: RED─GREEN─REFACTOR            │
│      ├─ HIGH ──► LGTM  │              4. AI Review (by confidence)          │
│      ├─ MEDIUM ► +Rev  │              5. Handle Deviations                  │
│      └─ LOW ───► +Rev+Chall           6. Quality Gate                       │
│   3-7. Review Cycle    │              7. Phase Complete ─► Loop             │
│   8. LGTM              │              8. Final LGTM                         │
│   9. Consistency       │              9. Sync Docs                          │
│   10. "Apply?" ────────┴─────────────►                                      │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Gemini Scripts

Script Role Temperature Purpose
gemini-reviewer.cjs Technical Validator 0.3 Feasibility, security, Clean Architecture
gemini-challenger.cjs Creative Disruptor 0.7 Alternatives, conviction scores
gemini-validator.cjs Compliance Checker 0.3 Plan compliance, deviation handling

Direct Script Usage

# Technical review
node .claude/skills/gemini-claude-loop/scripts/gemini-reviewer.cjs "Review this: [content]"

# Creative challenge
node .claude/skills/gemini-claude-loop/scripts/gemini-challenger.cjs "Challenge this: [content]"

# Compliance validation
node .claude/skills/gemini-claude-loop/scripts/gemini-validator.cjs "[implementation]" "[plan]"

Conviction Score System

Challenger provides conviction scores to prioritize feedback:

Score Meaning Required Action
9-10 Critical flaw in current approach MUST address
7-8 Significant improvement possible SHOULD address
5-6 Notable benefits Consider
3-4 Minor improvement Optional
1-2 Current approach is fine AGREE allowed

File Structure

gemini-claude-loop/
├── SKILL.md              # Main skill definition
├── PROPOSAL_LOOP.md      # 10-step proposal workflow
├── APPLY_LOOP.md         # 9-step implementation workflow
└── scripts/
    ├── gemini-reviewer.cjs     # Technical validation
    ├── gemini-challenger.cjs   # Creative alternatives
    └── gemini-validator.cjs    # Plan compliance

Requirements

  • Claude Code CLI
  • OpenSpec installed in project
  • Gemini API Key (gemini-3-pro-preview model)
  • Node.js 18+ (for running scripts)

Configuration

Coverage Targets (Customizable)

Layer Default Target
Domain 90%
Application 85%
Infrastructure 80%
UI 70%

Re-review Limits

  • Maximum 3 iterations per review cycle
  • After 3: escalate to user decision

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

MIT License - see LICENSE for details.

Related

Acknowledgments

Built for the OpenSpec community to enable higher-quality AI-assisted development through multi-model validation.

About

Triple AI validation skill for OpenSpec (Claude + Gemini)

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages