Context Forge

repository·main·Indexed 40 days ago

https://github.com/webdevtodayjason/context-forge

A CLI-based context engine for scaffolding Claude Code development surfaces. It automates the creation of settings, agents, skills, hooks, and over 20 slash commands to provide high-fidelity project context for AI IDEs including Claude, Cursor, Cline, Copilot, Windsurf, Gemini, and Roo Code. Features include Product Requirement Prompts (PRPs), a Migration Intelligence System for framework upgrades, and Python-based automation hooks for context management.

Tokens
119.8K
Snippets
270
Records
435
Agent score
100%

What's inside Context Forge

  1. Overview of generated project artifacts

    main

    Running context-forge init generates a structured set of files to provide AI IDEs with deep project context. The output structure depends on your selected generators, but typically includes:

    Core Context Files

    • CLAUDE.md: Tech-stack-aware project rules.
    • Docs/: Contains Implementation.md (staged dev plans), project_structure.md, and other documentation templates.
    • PRPs/: Project Readiness Plans (e.g., <project>-prp.md, <feature>-prp.md) used for structured implementation.

    Claude-Specific Surface (.claude/)

    • .claude/settings.json: The canonical configuration for Claude Code, including hooks, MCP servers, and permissions.
    • .claude/agents/: Markdown files defining sub-agents (e.g., code-reviewer.md, test-runner.md) with specific tools and models.
    • .claude/skills/: Project-specific procedures (e.g., testing-protocol/SKILL.md).
    • .claude/commands/: 21 specialized .md files for slash commands (e.g., orchestration, quality, migration).
    • .claude/hooks/: Bash and Python scripts triggered by lifecycle events (e.g., pre-tool-use.sh, session-start.sh).

    Internal Tracking

    • .context-forge/config.json: A record of the initialization settings used to replay or audit the setup.
  2. How Claude Code Slash Commands work

    main

    Slash commands in Context Forge are markdown files stored in .claude/commands/. They allow you to trigger structured, repeatable AI-assisted development workflows within Claude Code.

    Command Structure

    Each command file follows a specific format containing YAML frontmatter and a markdown body:

    name: command-name
    description: Brief description of the command
    category: PRPs|context|implementation|testing|documentation|custom
    
    ---
    
    # Command Title: $ARGUMENTS
    
    [Detailed instructions for Claude]

    Using Commands

    In Claude Code, invoke a command by typing / followed by the command name and any necessary arguments:

    /command-name your arguments here

    The $ARGUMENTS placeholder in the command file is automatically replaced by everything provided after the command name.

  3. Django Code Structure and Modularity Limits

    main

    To maintain code quality and readability, adhere to the following file and function size constraints:

    • File Limit: Never create a file longer than 500 lines of code.
    • View Limit: View functions or classes should be under 100 lines.
    • Model Method Limit: Model methods should be under 50 lines.
    • Complex Queries: Use Django Managers for complex query logic rather than embedding them in views or models directly.
  4. Structure of a PRP (Project Requirements Plan) template

    main

    A PRP (Project Requirements Plan) is a structured markdown template used to provide comprehensive context to AI coding agents for implementing specific features. It follows a hierarchical structure designed to move from high-level goals to low-level implementation details and validation steps.

    Core Sections

    1. Identity & Intent: Defines the projectName, featureName, goal, and reasons (the 'Why') for the feature.
    2. Contextual Requirements:
      • Success Criteria: A checklist of requirements that must be met.
      • Documentation & References: A list of URLs and the reasoning for why they must be included in the AI's context window.
      • Codebase Structure: Comparison between projectStructure (current) and desiredStructure (target).
      • Known Gotchas: Language-specific quirks or critical warnings.
    3. Implementation Blueprint:
      • Data Models: Definitions for type safety and consistency.
      • Task Breakdown: A YAML-formatted list of tasks, including files to modify and specific steps.
      • Implementation Details: Pseudocode or detailed logic for each task.
      • Integration Points: Specific instructions for DATABASE, CONFIG, and ROUTES updates.
    4. Validation Loop: A multi-level testing strategy:
      • Level 1 (Syntax & Style): Commands to run first to ensure code quality.
      • Level 2 (Unit Tests): Implementation of specific test cases in the target testLanguage.
      • Level 3 (Integration Test): Commands to start services and test endpoints.
      • Level 4 (Deployment & Creative Validation): Deployment commands and custom feature-specific validation.
    5. Final Checklist & Anti-Patterns: A final verification list and a list of antiPatterns to avoid during implementation.
  5. Use PRP (Product Requirement Prompt) for structured implementation

    main

    PRP files provide a structured approach to implementing features with clear validation gates between stages. This helps Gemini understand implementation phases and success criteria.

    PRP Workflow Commands

    • gemini prp status: View the current PRP implementation stage.
    • gemini generate --prp-stage <number>: Generate code specifically for a defined PRP stage (e.g., gemini generate --prp-stage 1).
    # View current PRP stage
    gemini prp status
    
    # Generate code for specific stage
    gemini generate --prp-stage 1
  6. Manage State using the Nuxt Hierarchy

    main

    Follow this hierarchy for state management to ensure proper scoping and performance:

    1. Component State: Use ref() and reactive() for state local to a single component.
    2. Nuxt State: Use useState() for state that needs to be shared across components within a page.
    3. Global State: Use Pinia stores for complex, application-wide state.
    4. Server State: Use useFetch() or useLazyFetch() for all API-driven data.
    5. Persistent State: Use useCookie() for user preferences or data that must survive refreshes.
    // 1. Component state
    const isOpen = ref(false);
    
    // 2. Nuxt cross-component state
    const user = useState<User | null>('user', () => null);
    
    // 3. Pinia store
    export const useAuthStore = defineStore('auth', () => {
      const user = ref<User | null>(null);
      const isAuthenticated = computed(() => !!user.value);
      
      return { user, isAuthenticated };
    });
    
    // 4. Server state
    const { data: users, pending, refresh } = await useFetch<User[]>('/api/users');
    
    // 5. Persistent state
    const theme = useCookie<'light' | 'dark'>('theme', {
      default: () => 'light',
    });
  7. Structure of a Planning Document (PRP) template

    main

    The planning.md template is used to generate a comprehensive Planning Document (often referred to as a PRP) for a project. It uses Handlebars-style placeholders to structure technical documentation including architecture diagrams, component breakdowns, technical decisions, and implementation phases.

    When using this template, the following sections are generated:

    • Executive Summary: High-level project overview.
    • Architecture Overview: Visual representation via Mermaid diagrams.
    • System Components: Detailed breakdown of each component's purpose, responsibilities, and dependencies.
    • Data Flow: Visual representation of data movement via Mermaid diagrams.
    • Technical Decisions: Documentation of options considered, the chosen path, and the rationale.
    • Implementation Phases: A phased roadmap including duration, goals, deliverables, and dependencies.
    • Risk Analysis: Assessment of risks including probability, impact, and mitigation strategies.
    • Security, Performance, Monitoring, and Future Considerations: Specialized technical requirement sections.
  8. Structure a PRP with Validation Loops and Implementation Blueprints

    main

    A complete PRP generated from this template should follow this logical flow to ensure an AI agent can successfully complete a task:

    1. Goal & Why: Defines the objective and the reasoning behind the change.
    2. Success Criteria: A checklist of requirements that must be met.
    3. Contextual Awareness:
      • Documentation: Links to specific docs and why they are needed.
      • AI Docs: Specific files in PRPs/ai_docs/ that are critical.
      • Codebase Trees: The current structure vs. the desired structure.
      • Gotchas: Known library quirks and framework version notes.
    4. Implementation Blueprint:
      • Data Models: Definitions for type safety.
      • Task List: Ordered tasks with specific files, actions, and patterns to follow.
      • Pseudocode: Detailed logic for each task.
      • Integration Points: Specifics for Databases, Config, Routes, and Environment variables.
    5. Validation Loops: Four levels of testing (Syntax, Unit, Integration, Deployment).
    6. Final Checklist: A summary of quality gates (e.g., no hardcoded values, comprehensive error handling).
  9. Base Enhanced Template (`base-enhanced`)

    main

    The base-enhanced template is the most comprehensive option, designed for full feature implementation. It focuses on deep context integration and strict quality control.

    Key Features

    • 4-Level Validation Gates: Syntax, Unit Tests, Integration, and Creative validation.
    • AI Documentation Integration: Supports referencing curated ai_docs/ files.
    • Common Fixes Section: Pre-populated solutions for typical errors.
    • Integration Points: Explicit sections for Database, Config, Routes, and Environment.

    When to Use

    • Standard feature implementation.
    • When maximum context is required.
    • Projects requiring strict validation.
    • Complex integrations.
    ## All Needed Context
    - Version-specific gotchas
    - Framework patterns
    - Testing conventions
    
    ## Model path: app/models/
    
    ## Database Integration
    - Migration patterns
    - Query examples
    
    ## Implementation Blueprint
    [Detailed pseudocode with validation points]
    
    ## Validation Gates
    
    ### Level 1: Syntax
    ✓ Run: npm run lint
    
    ### Level 2: Unit Tests
    ✓ Run: npm test
    
    ### Level 3: Integration
    ✓ Run: npm run test:e2e
    
    ### Level 4: Creative Validation
    - Performance benchmarks
    - Security scanning
    - User acceptance
  10. How Dart integration hooks work

    main

    When Dart integration is enabled, Context Forge generates three specialized Python hooks that automate task management by monitoring file changes and Git activity.

    1. DartProgressUpdater.py

    Purpose: Automatically updates task progress based on code changes and git commits. Triggers: File creation (Write), file modification (Edit, MultiEdit), and Git commits (Bash tool with git commit). Outputs: .claude/dart_progress.json and .claude/task_suggestions.json.

    2. AutoTaskCommenter.py

    Purpose: Adds detailed comments to tasks by analyzing code changes. Analysis: Tracks function/line counts, assesses complexity, and categorizes files (e.g., auth, API, UI). Outputs: .claude/task_comments.json and .claude/milestone_comments.json.

    3. TaskCodeMapper.py

    Purpose: Maintains the relationship between tasks and code files. Detection: Uses explicit patterns (e.g., task-123), category inference (e.g., auth/), and project keywords. Outputs: .claude/task_mapping.json and .claude/task_assignments.json.

  11. How the Migration Intelligence System works

    main

    The Migration Intelligence System provides AI-powered assistance to reduce the risk and manual effort of upgrading frameworks. It operates through several key capabilities:

    • Framework Detection: Automatically identifies 10+ frameworks with confidence scoring.
    • Breaking Change Analysis: Identifies version-specific breaking changes and determines if they can be automated.
    • Dependency Intelligence: Analyzes package incompatibilities and suggests suitable replacements.
    • Migration Phases: Breaks down the migration into a step-by-step plan with integrated checkpoints.
    • Risk Assessment: Provides a comprehensive risk analysis along with specific mitigation strategies.
  12. Adhere to Ruby on Rails development principles

    main

    When developing with this Ruby on Rails stack, follow these core design principles:

    • KISS (Keep It Simple, Stupid): Prioritize straightforward solutions over complex ones.
    • YAGNI (You Aren't Gonna Need It): Do not implement functionality based on speculation; only build what is currently required.
    • Convention over Configuration: Strictly follow standard Rails conventions.
    • DRY (Don't Repeat Yourself): Utilize Rails helpers and concerns to avoid duplication.
    • Fat Models, Skinny Controllers: Keep business logic within models rather than controllers.
    • RESTful Design: Use standard Rails resource routing.