5 min read
ai developer-tools

bkit: Structured PDCA Workflows and Context Engineering for Gemini CLI

TL;DR

ComponentCountPurpose
Specialized AI Agents21Role-based personas (CTO, architect, QA, PM) with permission grades
Domain Skills35On-demand expert knowledge via progressive disclosure
Custom Commands24TOML slash commands with @{}, !{}, {{}} syntax
Hook Events10Full Gemini CLI lifecycle interception
Team Patterns5Leader, Council, Swarm, Pipeline, Watchdog
Automation Levels5L0 (Manual) to L4 (Autonomous)
Languages8EN, KO, JA, ZH, ES, FR, DE, IT

Install: gemini extensions install https://github.com/popup-studio-ai/bkit-gemini.git — then run /bkit to start.

The Problem bkit Solves

AI coding assistants are powerful, but they lack structure. You ask Gemini CLI to build a feature, and it jumps straight to writing code — no planning, no design doc, no gap analysis. The result? Fragile implementations that drift from the original intent, inconsistent code quality, and no documentation trail.

bkit solves this by layering PDCA (Plan-Do-Check-Act) methodology on top of Gemini CLI through a concept its creators call Context Engineering.

Context Engineering vs Prompt Engineering

The distinction matters. Prompt engineering is about writing good prompts. Context Engineering is about designing systems that integrate prompts, tools, and state to provide LLMs with optimal context for inference.

bkit implements this through three layers:

LayerComponentsWhat It Does
Domain Knowledge35 skillsExpert knowledge loaded on-demand (progressive disclosure)
Behavioral Rules21 agentsRole-based constraints with model/tools/temperature configs
State Management17 hooks + 13 lib modulesPDCA tracking, intent detection, permissions, memory

Instead of one massive prompt, bkit injects only the context relevant to the current PDCA phase. The v2.0.0 guide reports 71% token savings from this phase-aware context loading — not through prompt tricks, but through architectural design.

The 10-Event Hook System

This is the core mechanism. bkit intercepts the entire Gemini CLI lifecycle:

Event 1: SessionStart -> Detect project level, load output style, inject PDCA context
Event 2: BeforeAgent -> 8-language intent detection, agent/skill auto-trigger
Event 3: BeforeModel -> PDCA phase-specific prompt augmentation
Event 4: AfterModel -> Response tracking, usage metrics
Event 5: BeforeToolSelection -> Phase-based tool filtering
Event 6: BeforeTool -> Permission manager, dangerous command blocking (exit code 2)
Event 7: AfterTool -> Auto PDCA phase transitions
Event 8: AfterAgent -> Cleanup, phase completion detection
Event 9: PreCompress -> Context fork snapshot preservation
Event 10: SessionEnd -> Session cleanup, memory persistence

The key automation: Event 7 auto-transitions PDCA phases. When you write your first source file in the Design phase, bkit automatically transitions to the Do phase. When you run analysis, it transitions to Check. You don’t have to remember which phase you’re in.

Dangerous commands are auto-blocked by Event 6: rm -rf, git reset --hard, git push --force, reverse shell patterns, and similar destructive operations are rejected before execution.

Getting Started

Prerequisites

  • Gemini CLI v0.34.0+ (v2.0.0 requirement)
  • Node.js v18+ (for hook scripts)
  • Git

Installation

Terminal window
gemini extensions install https://github.com/popup-studio-ai/bkit-gemini.git

Verify with /bkit in interactive mode or gemini extensions list in non-interactive mode.

Ensure Hooks Are Enabled

~/.gemini/settings.json
{
"hooksConfig": {
"enabled": true
}
}

Hooks are enabled by default, but it’s worth verifying. On first run, bkit auto-initializes and shows a Control Panel and Workflow Map.

First-Time User Options

OptionCommandTarget Audience
Learn bkit/development-pipelineFirst-time bkit users
Learn Gemini CLI/claude-code-learningFirst-time Gemini CLI users
New project/starter, /dynamic, /enterpriseNew projects
Free startNormal conversation modeExperienced users

Automation Levels: L0 Through L4

One of the most significant additions in v2.0.0 is the automation level system. You control how autonomous bkit is:

LevelNameBehavior
L0ManualEvery action requires user approval
L1Semi-AutoPDCA transitions auto, implementation requires approval
L2AutoRead actions auto, write actions require approval
L3Full-AutoMostly auto, dangerous commands only require approval
L4AutonomousFully autonomous (except dangerous commands)

Defaults: Starter=L0, Dynamic=L1, Enterprise=L1.

Terminal window
/control level L2 # Set automation level
export BKIT_PDCA_AUTOMATION=full-auto # Or via environment variable
/control stop # Emergency stop
Ctrl+C # Also triggers emergency stop + checkpoint save

The Core Workflow: PDCA

Every feature goes through the same 6-phase cycle. bkit enforces this — you can’t skip to implementation without a plan.

Plan

Terminal window
/pdca plan "user authentication with JWT and Google OAuth"

Creates docs/01-plan/features/user-authentication.plan.md with requirements, scope, and constraints. For deeper exploration:

Terminal window
/plan-plus "user authentication with JWT and Google OAuth"

This adds Intent Discovery, 3+ alternative comparisons, and YAGNI (You Aren’t Gonna Need It) review before committing to a plan.

Design

Terminal window
/pdca design "user authentication with JWT and Google OAuth"

Creates docs/02-design/features/user-authentication.design.md with architecture decisions, API contracts, and component structure. The design-validator agent checks completeness and consistency automatically.

Do

Terminal window
/pdca do "user authentication with JWT and Google OAuth"

Implementation phase. All tools are unlocked (Plan phase restricts to read-only). The permission manager blocks dangerous commands. AfterTool hooks track every file change. bkit’s Rule 5 applies: “Prefer editing existing files over creating new ones.”

Check

Terminal window
/pdca analyze "user authentication with JWT and Google OAuth"

The gap-detector agent compares the design document against the actual implementation and produces a Match Rate metric: (implemented items / designed items) × 100%. Target: >= 90%. Generates docs/03-analysis/user-authentication.analysis.md.

Act

Terminal window
# If Match Rate < 90% — iterate (max 5 iterations)
/pdca iterate "user authentication with JWT and Google OAuth"
# If Match Rate >= 90% — generate completion report
/pdca report "user authentication with JWT and Google OAuth"

The pdca-iterator agent uses the Evaluator-Optimizer pattern to auto-fix issues, re-running Check after each iteration. The report-generator creates docs/04-report/features/user-authentication.report.md when the match rate is acceptable.

Status, Archive, and Batch

Terminal window
/pdca status # Current PDCA state
/pdca next # Auto-advance guidance
/pdca archive auth # Archive completed PDCA docs
/pdca batch # View all active features (parallel PDCA, max 3)

State Management: Where bkit Stores Things

PDCA state is persisted in .bkit/state/pdca-status.json:

{
"primaryFeature": "user-authentication",
"features": {
"user-authentication": {
"phase": "check",
"matchRate": 87,
"iterations": 1,
"documents": {
"plan": "docs/01-plan/features/user-authentication.plan.md",
"design": "docs/02-design/features/user-authentication.design.md"
}
}
}
}

Memory operates at three tiers:

ScopeStoragePersistencePurpose
SessionIn-memoryCurrent session onlyTemporary state, intermediate results
Project.bkit/state/PermanentPDCA state, decision records
User~/.bkit/All projectsUser preferences, learning history

The starter-guide and pipeline-guide agents use User scope (shared across projects). The other 19 agents use Project scope.

Project Levels

bkit auto-detects your project type through directory/file scanning:

LevelDetection SignalsStackPDCA PhasesAutomation
StarterDefault (no special files)HTML, CSS, JS, Next.js4 of 6 (skips Check, Act)L0 (Manual)
Dynamicdocker-compose.yml, .mcp.json, lib/bkend, prisma/schema.prismaNext.js + bkend.ai BaaS5 of 6 (optional Act)L1 (Semi-Auto)
Enterprisekubernetes/, terraform/, docker-compose.prod.ymlK8s, Terraform, MonorepoAll 6 phasesL1 (Semi-Auto)

Force a level with BKIT_PROJECT_LEVEL=Enterprise or via gemini-extension.json.

Auto-detection works in 8 languages. Type “포트폴리오 웹사이트 만들고 싶어요” (Korean for “I want to make a portfolio website”) and bkit triggers the Starter skill automatically.

The 21 Agents with Permission Grades

Agents have permission grades that restrict what they can do:

GradeAgentsAllowed Tools
READONLYgap-detector, design-validatorRead-only only
DOCWRITEreport-generator, pm-prdRead + docs/ directory write only
FULLcto-lead, pdca-iterator, and most othersAll tools (except dangerous commands)

Each agent uses Gemini native frontmatter with configurable model, tools, temperature, max_turns, and timeout_mins. v2.0.0 uses updated models: gemini-3.1-pro, gemini-3-pro, and gemini-3-flash.

Here are the agents grouped by function:

PDCA Core (5):

AgentRoleTriggered By
cto-leadCTO-level team orchestration/bkit, PDCA workflows
gap-detectorDesign-implementation gap analysis (READONLY)“verify”, “검증”
pdca-iteratorAuto-iteration improvement, max 5 loops”improve”, “개선”
report-generatorPDCA completion report (DOCWRITE)“report”, “보고서”
design-validatorDesign completeness validation (READONLY)“validate design”

Code Quality (3):

AgentRoleTriggered By
code-analyzerCode quality, security, performance”analyze”, “분석”
qa-strategistTest strategy, QA planning”test strategy”
qa-monitorDocker log real-time monitoring”docker logs”

Architecture (4):

AgentRoleTriggered By
frontend-architectUI/UX, React, Next.js”component”, “UI”
security-architectOWASP, auth design”CSRF”, “XSS”, “보안”
infra-architectAWS, K8s, Terraform”K8s”, “AWS”
enterprise-expertMicroservices, AI-native”CTO”, “microservices”

PM Agent Team (5): Accessed via /pdca pm {feature} — 5 agents produce a full PRD with personas, competitive analysis, Lean Canvas, and GTM strategy.

Specialized (4): bkend-expert (28 MCP tools), starter-guide, pipeline-guide, product-manager.

Checkpoints and Rollback

bkit auto-saves a checkpoint at every PDCA phase transition. If something goes wrong, you can roll back:

Terminal window
/rollback list # List available checkpoints
/rollback restore {id} # Restore to a checkpoint
/rollback reset {feature} # Reset feature to initial state

Emergency stops (Ctrl+C or /control stop) automatically save a checkpoint. This is a safety net — you can always undo.

BTW: Recording Ideas Mid-Workflow

One of the most practical v2.0.0 additions is the BTW (By The Way) system. When you’re in the middle of a PDCA cycle and have an improvement idea, record it without interrupting your flow:

Terminal window
/btw API 응답 시간이 느린데 캐싱 추가하면 좋겠다 # Record an idea
/btw list # List recorded ideas
/btw analyze # Analyze feasibility
/btw promote {id} # Promote to full PDCA feature
/btw stats # View statistics

Ideas stay out of your current workflow until you’re ready to promote them.

Greenfield Example: Building a Task Management SaaS

Terminal window
# 1. Product discovery (5 PM agents collaborate)
/pdca pm "task management SaaS for remote teams"
# Produces: personas, competitive analysis, Lean Canvas, PRD, GTM strategy
# 2. Initialize as Dynamic project
/dynamic init "taskflow"
# 3. Plan Plus for deeper brainstorming
/plan-plus "user signup and login with Google OAuth"
# 4. PDCA each feature
/pdca plan "user signup and login with Google OAuth"
/pdca design "user signup and login with Google OAuth"
/pdca do "user signup and login with Google OAuth"
/pdca analyze "user signup and login with Google OAuth"
/pdca report "user signup and login with Google OAuth"
# 5. Parallel PDCA (max 3 concurrent features)
/pdca plan "todo CRUD with kanban board"
/pdca plan "real-time notifications"
# 6. Quality review
/review src/
/simplify
/qa

Result: docs/ contains plan, design, analysis, and report for every feature. Each agent remembers context across sessions. Checkpoints are auto-saved at every phase transition.

Brownfield Example: Adding Auth to an Existing Next.js App

Terminal window
cd ~/my-existing-nextjs-app
gemini
# bkit auto-detects Dynamic level
# Rule 5 enforced: "Prefer editing existing files over creating new ones"
/pdca plan "add authentication with role-based access control"
/pdca design "add authentication with role-based access control"
/pdca do "add authentication with role-based access control"
/pdca analyze "add authentication with role-based access control"
# If gap < 90%:
/pdca iterate "add authentication with role-based access control"
# If gap >= 90%:
/pdca report "add authentication with role-based access control"
# Rollback if something went wrong:
/rollback list
/rollback restore {checkpoint-id}
# Final code review
/review src/middleware.ts src/lib/auth.ts

The gap-detector compares the design doc against your existing codebase, accounting for brownfield constraints rather than assuming a clean implementation.

Enterprise Example: Team Orchestration

For Enterprise-level projects, agents form coordinated teams:

Terminal window
/pdca team user-authentication

This triggers a structured team composition:

CTO Lead (cto-lead):
├── Plan Team (Leader pattern)
│ ├── product-manager → requirements analysis
│ └── security-architect → security requirements
├── Design Team (Council pattern)
│ ├── frontend-architect → UI design
│ ├── bkend-expert → API design
│ └── security-architect → auth design
├── Check Team (Watchdog pattern)
│ ├── gap-detector → gap analysis
│ ├── code-analyzer → code quality
│ └── qa-monitor → log monitoring
└── Report (Pipeline pattern)
└── report-generator → final report

Each pattern serves a different purpose:

PatternArchitectureWhen Used
Leader1 lead + N workersPlan and Design phases
CouncilEqual peers, independent analysisArchitecture decisions
SwarmDynamic pool, parallel executionLarge-scale code review
PipelineSequential chainPDCA auto-progression
WatchdogMonitor + actorsQA/security verification

The 9-Phase Development Pipeline

Beyond PDCA, bkit offers a 9-phase pipeline for comprehensive project scaffolding:

PhaseDescriptionStarterDynamicEnterprise
1. SchemaTerminology and data modelsRequiredRequiredRequired
2. ConventionCoding rules and standardsRequiredRequiredRequired
3. MockupUI/UX wireframesRequiredRequiredRequired
4. APIREST endpoint designSkipRequiredRequired
5. Design SystemComponent librarySkipOptionalRequired
6. UI IntegrationFrontend-to-backend wiringRequiredRequiredRequired
7. SEO/SecurityHardeningSkipOptionalRequired
8. ReviewArchitecture reviewSkipOptionalRequired
9. DeploymentCI/CD and productionRequiredRequiredRequired
Terminal window
/development-pipeline start # Start from phase 1
/development-pipeline status # Show current phase
/development-pipeline next # Advance to next phase
/phase-4-api # Jump to a specific phase

Additional Commands

Terminal window
# Code quality
/review <path> # Code review with code-analyzer agent
/simplify # Code quality review and complexity reduction
/qa # Zero-script QA via Docker log monitoring
# Automation
/loop 5m /pdca status # Recurring command execution
# Audit trail
/audit # View full audit log
/audit {feature} # Audit specific feature
/audit decisions # View all recorded decisions
# Custom skills
/skill-create # Create project-specific skill (hot-reload supported)

The audit log tracks decisions, tool usage, phase transitions, agent activity, and security events — all stored in .bkit/audit/.

Output Styles

Choose a response style that matches your experience level:

Terminal window
/output-style-setup
StyleDefault ForCharacteristics
bkit-learningStarterBeginner-friendly, “Why?” sections, code comments, tips
bkit-pdca-guideDynamicPDCA-centric, phase indicators, action→result→next flow
bkit-enterpriseEnterpriseEfficiency-first, minimal explanation, technical terminology
bkit-pdca-enterpriseEnterprise (optional)PDCA + Enterprise combined

Set via /output-style-setup or the BKIT_OUTPUT_STYLE environment variable.

23 Built-in Tools

bkit maps and manages Gemini CLI’s 23 built-in tools, including file management (7), execution (1), info search (2), agent coordination (5), plan mode (2), and Task Tracker tools (6, requires v0.32.0+).

Environment Variables

VariablePurpose
BKIT_PROJECT_LEVELOverride auto-detected project level
BKIT_PDCA_AUTOMATIONSet automation level (e.g., full-auto)
BKIT_OUTPUT_STYLESet output style

When to Use bkit

bkit is worth the setup overhead when:

  • You’re building features that benefit from design docs and gap analysis
  • You want consistent development processes enforced automatically
  • You’re working with Gemini CLI and want more structure than raw prompting
  • You’re building a greenfield project that needs systematic scaffolding
  • You’re adding features to a brownfield project and need design-to-implementation traceability
  • You want AI autonomy with guardrails (L2-L4 automation levels)
  • You need audit trails and rollback safety for AI-assisted development

When bkit Is Overkill

  • Quick scripts and one-off tasks
  • Projects that don’t benefit from formal PDCA cycles
  • Teams already using a different project management methodology
  • Environments where you can’t install Gemini CLI extensions
  • Developers who prefer fully manual control over every AI action

Key Takeaways

  1. PDCA is enforced by hooks — you can’t skip planning, even if you try
  2. Context Engineering is architectural — 71% token savings from phase-aware context loading
  3. Automation levels L0-L4 — start manual, scale to autonomous as you gain trust
  4. Checkpoints and rollback — every phase transition auto-saves, emergency stop included
  5. Agent permission grades — READONLY, DOCWRITE, and FULL prevent agents from overstepping
  6. BTW system — record improvement ideas without interrupting your current workflow
  7. Parallel PDCA — up to 3 features simultaneously via /pdca batch
  8. Multi-language auto-detection — works in 8 languages, triggers agents automatically
  9. Team orchestration — 5 patterns for coordinated multi-agent workflows (Enterprise)
  10. Audit trail — full logging of decisions, tool usage, phase transitions, and security events

bkit turns Gemini CLI from a raw AI assistant into a structured development environment. It won’t write better code than Gemini already can — but it ensures the code is planned, designed, verified, documented, and auditable in a systematic way that raw prompting never achieves.

This article was written by opencode (GLM-5 Turbo), based on content from: https://github.com/popup-studio-ai/bkit-gemini and the bkit-gemini v2.0.0 User Guide