Skip to content

/discover-context

Explore and understand existing code context, patterns, and architecture to inform development decisions.

Overview

  • Purpose: Intelligent codebase exploration
  • Category: Core Orchestration
  • Type: Dynamic prompt
  • MCP Tools: None (code analysis)

Syntax

bash
/discover-context [area] [focus]

Usage Examples

bash
# General discovery
/discover-context

# Specific area
/discover-context "authentication"

# Pattern discovery
/discover-context patterns "API structure"

# Architecture exploration
/discover-context architecture "microservices"

Discovery Process

Code Analysis

  • File structure mapping
  • Dependency analysis
  • Pattern identification
  • Convention detection

Context Building

  • Understand relationships
  • Identify key components
  • Map data flow
  • Document decisions

Knowledge Synthesis

  • Summarize findings
  • Extract patterns
  • Identify gaps
  • Suggest improvements

Output Example

🔍 Discovering Project Context

## Project Structure
Type: Monorepo
Framework: Next.js 14 with App Router
Language: TypeScript (strict mode)
Testing: Jest + React Testing Library

## Key Discoveries

### Authentication System
- Location: src/lib/auth/
- Type: JWT with refresh tokens
- Provider: Custom implementation
- Session: Server-side cookies

### API Structure  
- Pattern: RESTful with consistent naming
- Location: app/api/
- Middleware: Auth, rate limiting, CORS
- Error handling: Centralized

### Database Layer
- ORM: Prisma
- Database: PostgreSQL
- Migrations: Up to date
- Seeds: Development data available

### State Management
- Client: Zustand for global state
- Server: React Server Components
- Cache: Redis for sessions

## Patterns Found
1. Consistent error handling
2. Shared validation schemas
3. Modular feature structure
4. Co-located tests

## Architecture Insights
- Clean separation of concerns
- API-first design
- Progressive enhancement
- Security-first approach

## Recommendations
1. Extract common patterns to utilities
2. Add API documentation
3. Implement integration tests
4. Consider error boundary strategy

## Context Saved
✅ Updated project CLAUDE.md
✅ Created architecture diagram
✅ Documented key patterns

Discovery Types

Architecture Discovery

bash
/discover-context architecture

Maps:

  • System components
  • Data flow
  • Integration points
  • Dependencies

Pattern Discovery

bash
/discover-context patterns

Identifies:

  • Code patterns
  • Naming conventions
  • File organization
  • Common utilities

Technology Discovery

bash
/discover-context tech-stack

Finds:

  • Frameworks used
  • Libraries included
  • Tools configured
  • Services integrated

Best Practices

Prompt Adaptation

This prompt dynamically adapts based on:

Context Discovery

  • Analyzes current project state and structure
  • Discovers existing patterns and conventions
  • Understands team workflows and preferences
  • Adapts to technology stack and architecture

Intelligence Patterns

  • Learns from previous executions in the project
  • Adapts complexity based on team expertise
  • Prioritizes based on project phase
  • Suggests optimizations from accumulated knowledge

Memory Integration

This prompt actively uses and updates distributed memory:

Reads From

  • CLAUDE.md - Project context and conventions
  • .orchestre/ - Orchestration state and patterns
  • Feature-specific CLAUDE.md files
  • Previous execution results

Updates

  • Relevant CLAUDE.md files with new insights
  • .orchestre/ with execution patterns
  • Documentation as part of the workflow
  • Pattern library with successful approaches

1. Discover Before Building

bash
# Before adding features
/discover-context "payment system"
/execute-task "Add payment processing"

2. Regular Exploration

bash
# Weekly context updates
/discover-context --recent
/update-state "New patterns discovered"

3. Share Discoveries

bash
/discover-context
/document-feature "architecture overview"

Integration

With Planning

bash
/discover-context
/orchestrate "Build on existing patterns"

With Learning

bash
/discover-context patterns
/learn "Apply discovered patterns"

With Documentation

bash
/discover-context "API structure"
/document-feature "API patterns"

Advanced Usage

Focused Discovery

bash
# Security audit
/discover-context security "authentication and authorization"

# Performance analysis
/discover-context performance "database queries"

# Dependency check
/discover-context dependencies "external services"

Comparison Discovery

bash
# Compare with best practices
/discover-context --compare "industry standards"

# Evolution tracking
/discover-context --changes "last month"

Direct Invocation

This is a dynamic prompt that Claude executes directly - no file installation needed:

bash
# Simply type the command
/discover-context [parameters]

# Claude will:
# 1. Analyze current context
# 2. Discover relevant patterns
# 3. Execute intelligently
# 4. Update distributed memory
# 5. Provide detailed results

Built with ❤️ for the AI Coding community, by Praney Behl