CTX: Context as Code (CaC) tool

Official
by context-hub
MIT License
80
  • Apple
  • Linux

Integrations

  • Extracts code changes from Git commits and diffs to provide contextual information about your project's history

  • Gathers code from GitHub repositories to provide context about your project to LLMs

  • Supports specialized handling of PHP code, including the ability to extract PHP signatures without implementation details

ctx: コードベースと LLM 間の欠けているリンク。MCP サーバーを内蔵した Context as Code (CaC) ツール。

目次

CTX は、ChatGPT や Claude などの LLM とチャットする際の大きな問題、つまりプロジェクトに関する十分なコンテキストを提供するという問題を解決するために作成されたツールです。

Mediumには Context Generator に関する記事があり、プロジェクトの背後にある動機とそれが解決する問題について説明しています。

AI開発において、コンテキストは単なる便利な情報ではなく、全てを左右します。コードベース全体を毎回手動でコピーしたり説明したりする代わりに、ctxは以下の情報から整理されたコンテキストファイルを自動的に構築します。

  • コードファイル、
  • GitHubとGitlabのリポジトリ
  • Gitのコミットと差分
  • CSSセレクターを含むWebページ(URL)
  • MCPサーバー
  • およびプレーンテキスト。

これは**、Claude のような AI 言語モデルにコードベースに関する必要なコンテキストを効率的に提供するという一般的な問題を解決するために作成されました。**

仕組み

  1. ファイル、ディレクトリ、GitHub または Gitlab リポジトリ、Web ページ、またはプレーン テキストからコードを収集します。
  2. パターンマッチング、コンテンツ検索、サイズ、日付フィルターを通じて特定のファイルをターゲットにします
  3. オプションの修飾子を適用する(実装の詳細なしで PHP 署名を抽出するなど)
  4. コンテンツを整理して、構造化されたマークダウン文書にする
  5. LLMと共有できるコンテキストファイルを保存します
  6. オプションでMCPサーバーを通じてコンテキストを提供し、クロードのようなAIアシスタントがプロジェクト情報に直接アクセスできるようにします。

クイックスタート

CTXの使い始めは簡単です。以下の簡単な手順に従って、最初のコンテキストファイルを作成してください。

1. CTXをインストールする

インストール スクリプトを使用してツールをダウンロードしてインストールします。

curl -sSL https://raw.githubusercontent.com/context-hub/generator/main/download-latest.sh | sh

これにより、 ctxコマンドがシステム (通常は/usr/local/bin ) にインストールされます。

**さらにオプションが必要ですか?**代替インストール方法については、完全なインストール ガイドを参照してください。

2. 設定ファイルを初期化する

プロジェクト ディレクトリに新しい構成ファイルを作成します。

ctx init

これにより、開始するための基本構造を持つcontext.yamlファイルが生成されます。

使用可能なすべてのコマンドとオプションについては、コマンド リファレンスを確認してください。

3. プロジェクトの構造を説明する

生成されたcontext.yamlファイルを編集して、含めるコードまたはコンテンツを指定します。

例えば:

$schema: 'https://raw.githubusercontent.com/context-hub/generator/refs/heads/main/json-schema.json' documents: - description: "User Authentication System" outputPath: "auth-context.md" sources: - type: file description: "Authentication Controllers" sourcePaths: - src/Auth filePattern: "*.php" - type: file description: "Authentication Models" sourcePaths: - src/Models filePattern: "*User*.php"

この構成ではsrc/Authディレクトリからすべての PHP ファイルと、 src/Modelsディレクトリから名前に「User」が含まれるすべての PHP ファイルが収集されます。

さらに高度な設定が必要ですか?

4. コンテキストを構築する

次のコマンドを実行してコンテキスト ファイルを生成します。

ctx

CTX は設定を処理し、指定された出力ファイル (この例ではauth-context.md ) を作成します。

ヒント: 詳細な出力を得るには、 -v-vv 、または-vvvログを設定します。

5. LLMと共有する

生成されたコンテキストファイルを、お気に入りのLLM(ChatGPTやClaudeなど)にアップロードまたは貼り付けてください。これで、コードベースに関する具体的な質問をすることができ、LLMは必要なコンテキストに基づいて正確なサポートを提供できるようになります。

プロンプトの例:

認証システムのコードを共有させていただきました。ユーザー登録プロセスにおける潜在的なセキュリティ上の脆弱性を特定するお手伝いをお願いできますか?

次のステップ: AI を活用した開発ワークフローにコンテキスト生成を統合するためのベスト プラクティスについては、 「コンテキスト ジェネレータを使用した開発」を参照してください。

これで完了です。コードベースに関する適切なコンテキストを使用して LLM を活用する準備が整いました。

6. Claude AIに接続する(オプション)

よりシームレスなエクスペリエンスを実現するには、MCP サーバーを使用して Context Generator を Claude AI に直接接続できます。

Claude AI をコードベースに直接接続できる MCP サーバーが組み込まれています。

MCP クライアントをコンテキスト ジェネレーター サーバーにポイントします。

{ "mcpServers": { "ctx": { "command": "ctx server -c /path/to/your/project" } } }

**注:**詳細なセットアップ手順については、 MCP サーバーの詳細をご覧ください。

コンテキスト ファイルを手動でアップロードしなくても、コードベースについて Claude に質問できるようになりました。

完全なドキュメント

利用可能なすべての機能と構成オプションを含む完全なドキュメントについては、次の Web サイトをご覧ください。

https://docs.ctxgithub.com


ライセンス

このプロジェクトは MIT ライセンスに基づいてライセンスされています。

-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

CTX は、ChatGPT や Claude などの LLM とチャットする際の大きな問題、つまりプロジェクトに関する十分なコンテキストを提供することを解決するために作成されたツールです。

  1. Table of Contents
    1. How it works
      1. Quick Start
        1. 1. Install CTX
        2. 2. Initialize a Configuration File
        3. 3. Describe Your Project Structure
        4. 4. Build the Context
        5. 5. Share with an LLM
        6. 6. Connect to Claude AI (Optional)
        7. Full Documentation

      Related MCP Servers

      • A
        security
        A
        license
        A
        quality
        Enables integration of Perplexity's AI API with LLMs, delivering advanced chat completion by utilizing specialized prompt templates for tasks like technical documentation, code review, and API documentation.
        Last updated -
        1
        94
        8
        JavaScript
        MIT License
        • Linux
      • -
        security
        F
        license
        -
        quality
        A Model Context Protocol server for Claude Desktop that provides structured memory management across chat sessions, allowing Claude to maintain context and build a knowledge base within project directories.
        Last updated -
        TypeScript
      • A
        security
        F
        license
        A
        quality
        A model context protocol server that allows interaction with TriliumNext Notes, providing tools to create, search, retrieve, update, and delete notes through natural language commands.
        Last updated -
        5
        1
        JavaScript
        • Apple
      • -
        security
        A
        license
        -
        quality
        An MCP server that provides integration with Microsoft's AutoGen framework, enabling multi-agent conversations through a standardized interface.
        Last updated -
        1
        Python
        MIT License

      View all related MCP servers

      ID: qn88dl0i3i