This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bundle install- Install Ruby dependenciesbin/blueprintsCLI- Run the CLI application (launches interactive menu if no args)bundle exec rspec- Run tests (RSpec test framework)bundle exec rubocop- Run linting/code style checksbundle exec yard doc- Generate documentationbundle exec pry- Start interactive Ruby consolebin/blueprintsCLI docs generate <file_path>- Generate AI-powered YARD documentation for Ruby files
Note: The Rakefile references config/database.yml but the actual file is at lib/blueprintsCLI/config/database.yml. Database migrations are located in lib/blueprintsCLI/db/migrate/.
rake db:create- Create the PostgreSQL databaserake db:migrate- Run database migrationsrake db:drop- Drop the databaserake db:seed- Seed the database with initial data
The main entry point is bin/blueprintsCLI which provides:
bin/blueprintsCLI blueprint submit <file_or_code>- Submit a new code blueprintbin/blueprintsCLI blueprint list [--format FORMAT]- List all blueprintsbin/blueprintsCLI blueprint search <query>- Search blueprints using vector similaritybin/blueprintsCLI blueprint view <id> [--analyze]- View a specific blueprintbin/blueprintsCLI blueprint edit <id>- Edit an existing blueprintbin/blueprintsCLI blueprint delete <id> [--force]- Delete a blueprintbin/blueprintsCLI blueprint export <id> [output_file]- Export blueprint codebin/blueprintsCLI config [setup|show|edit|validate|reset]- Manage configurationbin/blueprintsCLI docs generate <file_path>- Generate AI-powered YARD documentation
bin/blueprintsCLI- Launches interactive menu system for all operations
The application uses a dynamic command discovery system:
-
CLI Layer (
lib/blueprintsCLI/cli.rb) - Thor-based interface that auto-discovers command classes -
Commands (
lib/blueprintsCLI/commands/) - Command classes that handle routing and validation:BaseCommand- Abstract base providing logging and command metadataBlueprintCommand- Main blueprint operations with subcommand routingConfigCommand- Configuration management operationsDocsCommand- AI-powered YARD documentation generationMenuCommand- Interactive menu system (not exposed via CLI discovery)
-
Actions (
lib/blueprintsCLI/actions/) - Business logic layer performing actual operations -
Database (
lib/blueprintsCLI/database.rb) - PostgreSQL interface with pgvector for semantic search -
Generators (
lib/blueprintsCLI/generators/) - AI-powered content generation -
Agents (
lib/blueprintsCLI/agents/) - Sublayer AI interaction layer -
Services (
lib/blueprintsCLI/services/) - Service layer including YardocService for documentation generation
- Thor - Command-line interface framework with dynamic command registration
- Sublayer - AI framework for LLM interactions (configured for Gemini)
- RubyLLM - Multi-provider LLM interface supporting Gemini, OpenAI, Anthropic, DeepSeek
- PostgreSQL + pgvector - Database with 768-dimensional vector similarity search
- Sequel ORM - Database abstraction layer
- TTY toolkit - Rich terminal UI components (prompts, tables, menus, etc.)
- TTY::Config - Unified configuration management with environment variable mapping
Uses Google Gemini API (gemini-2.0-flash model) for:
- Automatic description generation from code analysis
- Category classification and tagging
- Blueprint name generation
- Vector embeddings for semantic search (768-dimensional vectors via
text-embedding-004) - AI-powered YARD documentation generation with comprehensive prompting system
blueprintstable - Stores code, metadata, and vector embeddingscategoriestable - Stores category definitionsblueprints_categoriestable - Many-to-many relationship
Uses TTY::Config for unified configuration management with multiple sources and validation:
lib/blueprintsCLI/config/*.yml- Default configuration files~/.config/BlueprintsCLI/config.yml- User configuration (created by config command)- Environment variables with
BLUEPRINTS_prefix automatically mapped - Backward compatibility with legacy config files
Key environment variables:
GEMINI_API_KEYorGOOGLE_API_KEY- Required for AI featuresOPENAI_API_KEY- For OpenAI providerANTHROPIC_API_KEY- For Anthropic providerDEEPSEEK_API_KEY- For DeepSeek providerBLUEPRINT_DATABASE_URLorDATABASE_URL- Database connectionRACK_ENV- Environment setting (defaults to 'development')
Configuration validation ensures required values are present and properly formatted.
Commands follow a consistent pattern:
- Inherit from
BaseCommandwith auto-generated command names - Implement
execute(*args)with subcommand routing - Delegate business logic to Action classes
- Actions inherit from
Sublayer::Actions::Base
The CLI auto-discovers commands by scanning BlueprintsCLI::Commands constants, excluding BaseCommand and MenuCommand. The system dynamically registers Thor commands based on class names, allowing for easy command extension.
- Direct CLI:
bin/blueprintsCLI <command> <subcommand> [args] - Interactive Menu:
bin/blueprintsCLI(no args) launchesMenuCommandwith guided workflows
Both approaches route to the same underlying command classes but provide different user experiences.
- Database configuration:
lib/blueprintsCLI/config/database.yml(notconfig/database.yml) - Migrations:
lib/blueprintsCLI/db/migrate/ - Models:
lib/blueprintsCLI/db/models/ - The Rakefile references the wrong config path and needs to be updated or migration commands run from the correct context
- Uses RSpec test framework (
bundle exec rspec) - Test files located in
spec/directory - Includes model specs, service specs, and request specs
- Factory definitions in
spec/factories.rb
- RuboCop for linting with multiple extensions (rspec, sequel, shopify, etc.)
- YARD for documentation generation
- Ruby LSP and Solargraph for development tooling
- AI-powered documentation generation via DocsCommand
BlueprintsCLI now features an enhanced logging system that automatically captures context information:
- Automatic Context Capture: Logs automatically include class name, method name, file, and line number
- Configurable Detail Levels: Choose between minimal, standard, or full context detail
- Performance Optimized: Context extraction is cached and optimized for performance
- Backward Compatible: All existing logging calls continue to work unchanged
logger:
context_enabled: true # Enable/disable context capture
context_detail_level: full # Options: minimal, standard, full
context_cache_size: 1000 # Cache size for performance optimization- minimal: Just class and method names
- standard: Class, method, and file name
- full: Class, method, file name, line number, and full path
The enhanced logging works automatically with existing logging calls:
logger.info("Processing data")
# Output: ℹ info Processing data class=MyClass method=process_data file=my_class.rb line=45- Commands use Thor for CLI interface with dynamic discovery
- Business logic separated into Action classes inheriting from Sublayer::Actions::Base
- Service layer for complex operations like YARD documentation generation
- Database interface abstraction with pgvector for semantic search
- Unified configuration management with TTY::Config supporting validation and environment mapping