DevContext

repository·main·Indexed 42 days ago

https://github.com/iamunbounded/devctx

A CLI tool and VS Code extension for capturing and persisting AI coding context—including intent, decisions, and progress—across sessions and team members. Version 0.5.0 features include an MCP server integration for AI agents, automated Git post-commit hooks, and commands to save, resume, and compress context history to prevent re-explaining codebases to LLMs.

Tokens
11.5K
Snippets
45
Records
59
Agent score
53%

What's inside DevContext

  1. Use DevContext features in VS Code

    main

    The DevContext extension provides several tools to manage your AI coding context:

    • Auto-Capture: Automatically captures context whenever you save files.
    • Save Context: Manually save your current progress using a structured format that includes: Task, Approaches, Decisions, State, Next Steps, and Blockers.
    • Resume Context: Load and continue working from a previously saved session.
    • Log: Access and view your session history.
    • Diff: View the differences between your current state and the last time you saved context.
  2. How DevContext manages context

    main

    DevContext stores data in a .devctx/ folder within your repository. It captures the following dimensions of your work to build a persistent 'intent history':

    • Task: What you are doing
    • Goal: Why you are doing it
    • Approaches: What you tried (and what failed)
    • Decisions: Key architectural choices
    • State: Where you left off

    This approach works with any AI tool because it focuses on managing the prompt—the universal interface for LLMs.

  3. Quick Start with DevContext

    main

    Follow these steps to start tracking your intent history in a repository:

    1. Initialize: Set up DevContext in your current repository.
    2. Work and Save: After a coding session, run devctx save to enter interactive prompts that capture your Task, Approaches, Decisions, and Next Steps.
    3. Resume: Run devctx resume to copy a perfectly formatted prompt to your clipboard. You can then paste this into any AI tool (Cursor, Claude, ChatGPT, etc.) to restore your full context.
    # 1. Initialize in your repo
    devctx init
    
    # 2. Work on your code... then save context
    devctx save
    
    # 3. Resume in ANY editor
    devctx resume
  4. Install and set up DevContext for VS Code

    main

    To use the DevContext VS Code extension, you must first ensure the DevContext CLI is installed and your project is under Git version control.

    1. Install the CLI: Install the devctx CLI globally via npm.
    2. Initialize Git: Ensure the workspace you are working in has a Git repository initialized.
    3. Install Extension: Install the DevContext extension from the VS Code Marketplace.
    npm install -g devctx
  5. Integrate DevContext as an MCP Server

    main

    To allow AI agents like Claude Code or Windsurf to natively read and write context, add DevContext to your Model Context Protocol (MCP) configuration. This exposes tools like devctx_save, devctx_resume, devctx_log and the resource devctx://context.

    {
      "mcpServers": {
        "devctx": {
          "command": "npx",
          "args": ["-y", "devctx", "mcp"]
        }
      }
    }
  6. Configure DevContext extension settings

    main

    You can customize the behavior of the DevContext extension using the following VS Code settings:

    • devctx.autoResume: A boolean setting to enable or disable the automatic resumption of context when you start VS Code.
    • devctx.defaultBranch: Specifies the default Git branch used to track context.
  7. View DevContext output in the Output Channel

    main

    All DevContext information (resumed context, logs, and diffs) is displayed in a dedicated VS Code Output Channel named DevContext.

    When you run commands like resume, log, or diff, the extension clears the channel and appends a header (e.g., ═══ DevContext Resume ═══) followed by the output from the devctx CLI.

  8. Initialize DevContext in a repository

    main

    To start using DevContext in a project, you must initialize it within a Git repository. This command creates a .devctx/ directory to store session data and configuration, and automatically updates your .gitignore to ensure context data is not committed to version control.

    What happens during initialization:

    1. Directory Creation: Creates .devctx/sessions and .devctx/branches directories.
    2. Configuration: Generates a config.json file inside .devctx/ containing the version, creation timestamp, and repository name.
    3. Git Integration: Appends .devctx/ to your .gitignore file.

    Prerequisites:

    • The project must be a valid Git repository. If it is not, run git init before initializing DevContext.
    # Note: The specific CLI command name is inferred as `devctx init` based on the file path and context.
    ```bash
    devctx init
  9. Manage DevContext via the VS Code Status Bar

    main

    The DevContext extension adds a status bar item to your VS Code window to provide quick access to your context and visual feedback on your last activity.

    • Resume Context: Clicking the status bar item triggers the devctx.resume command, which displays your saved context in the DevContext Output Channel.
    • Activity Indicator: The status bar displays the timestamp of your last DevContext entry (e.g., $(history) DevCtx: [2023-10-27 10:00:00]). If no context is found, it displays $(history) DevCtx: No context.
  10. Configure the watch interval

    main

    You can control how frequently DevContext performs an auto-save in watch mode.

    1. Via CLI Flag: Use the --interval flag to specify the interval in minutes.
    2. Via Configuration: Set the watchInterval key in your DevContext configuration file. The value is interpreted as minutes.

    If no interval is provided via the CLI, the command falls back to the watchInterval value defined in your configuration.

  11. Configure DevContext via config.json

    main

    DevContext settings are managed through a .devctx/config.json file. The configuration controls output behavior, Git integration, and AI provider settings. If the file is missing or malformed, DevContext falls back to its default settings.

    Configuration Keys

    KeyTypeDefaultDescription
    defaultOutput"clipboard""clipboard"Output mode for resuming context: "clipboard" or "stdout".
    autoGitCapturebooleantrueWhether to auto-detect and include Git information in the context.
    recentCommitCountnumber5Number of recent commits to capture for context.
    defaultLogCountnumber10Default number of log entries to include.
    watchIntervalnumber5Watch mode auto-save interval in minutes.
    autoHookbooleanfalseWhether a Git hook is automatically installed during initialization.
    aiProviderstring"https://api.openai.com/v1"Base URL for the AI provider (must be OpenAI-compatible).
    aiModelstring"gpt-4o-mini"The name of the AI model to use.
    aiApiKeystring (optional)undefinedAI API key. It is recommended to use the DEVCTX_AI_KEY environment variable instead of setting it here.