Learn Claude Code Rsのロゴ

Learn Claude Code Rs

コミュニティ
wulawulu

Build an AI agent harness in Rust, from a minimal loop to tools, subagents, memory, teams, worktrees, MCP, and typed tool routing.

公開者wulawulu
リポジトリlearn-claude-code-rs
言語Rust
フォーク
27
スター
139
利用可能なツール
0
通信方式stdio
ライセンスMIT
リンク
  • ツールをAIワークフローに接続

    Learn Claude Code Rsは、対応するAIクライアントやAIエージェントから利用できるMCP機能を提供します。

  • 0個の利用可能なツール

    呼び出し可能なアクションを以下で確認できます。サーバーから提供されている場合は、名前や説明も表示されます。

  • コピーして使える設定

    セットアップ用の設定例を使って、お好みのMCPクライアントにこのサーバーを設定できます。

  • オープンソースの注目度

    リンク先のリポジトリには139件のスターと27件のフォークがあります。

CI

learn-claude-code-rs

English | 中文

A progressive AI Agent Harness tutorial written in Rust.

This repository is a Rust-oriented learning path for building an agent harness. It starts with the smallest agent loop and gradually adds tools, planning, subagents, skills, context compaction, permissions, hooks, memory, multi-agent collaboration, worktree isolation, MCP/plugins, tool routing, and agent evaluation.

This project was inspired by shareAI-lab/learn-claude-code. Its chapter design, content organization, and some code ideas reference that project to a certain extent, then reimplement and adapt them for the Rust ecosystem. It is not a line-by-line copy or a simple port; it reorganizes the agent harness topic itself into a runnable Rust tutorial.

Each chapter is an independent runnable Rust crate. You can read them in order or jump directly into a topic to see how a harness capability is expressed through data structures, runtime loops, tool interfaces, and durable state.

Why This Repo

Most LLM examples stop at tool calling. This repo focuses on the runtime around the model:

  • tool dispatch
  • permissions
  • skills
  • memory
  • context compaction
  • subagents
  • background work
  • team protocols
  • worktree isolation
  • MCP plugins
  • typed tool routing
  • agent evaluation

Architecture

learn-claude-code-rs architecture

Audience

  • People who want to understand the internals of coding agents instead of only using existing products.
  • People who want to write AI agents, CLI tools, or automation tools in Rust.
  • Readers who already know LLM APIs and want to learn tool use, subagents, permissions, hooks, memory, and related engineering structures.
  • People interested in the infrastructure behind Claude Code, Codex, Devin, Cursor Agent, and similar coding agents.

Quick Start

Prepare Rust:

bash
rustup update
cargo --version

Configure the model API. The examples use an Anthropic-compatible SDK interface and read configuration from environment variables:

bash
cp .env.example .env

Edit .env:

bash
ANTHROPIC_API_KEY=your_api_key
ANTHROPIC_BASE_URL=your_anthropic_compatible_base_url
ANTHROPIC_MODEL=your_model_name

Run the first chapter:

bash
cargo run -p s01_agent_loop

Run the integrated version:

bash
cargo run -p sfull

Check the whole workspace:

bash
cargo check --workspace

Learning Path

Each chapter is an independent crate that can be run, read, and modified on its own. Reading in order is recommended because later chapters build on earlier structures.

ChapterDirectoryTopicDescription
01s01_agent_loopAgent LoopMinimal runnable agent with user input, model response, tool calling, and a basic bash tool. Docs: s01.en.md.
02s02_tool_useTool UseExtract tools into a trait and add read_file, write_file, and edit_file. Docs: s02.en.md.
03s03_todo_writeTodo PlanningAdd a todo tool so the agent can maintain a plan and execution state. Docs: s3.en.md.
04s04_subagentSubagentStart fresh-context subagents for delegated exploration or subtasks. Docs: s4.en.md.
05s05_skill_loadingSkill LoadingLoad skills from skills/ and inject skill content into context on demand. Docs: s05.en.md.
06s06_context_compactContext CompactCompact long context while preserving key state. Docs: s06.en.md.
07s07_permission_systemPermissionAdd permission modes and interactive confirmation for tool calls. Docs: s07.en.md.
08s08_hook_systemHook SystemAdd lifecycle hooks around tool execution and agent events. Docs: s08.en.md.
09s09_memory_systemMemoryAdd durable memory for preferences, facts, feedback, and references. Docs: s09.en.md.
10s10_system_promptSystem PromptManage system prompts through structured sections and templates. Docs: s10.en.md.
11s11_error_recoveryError RecoveryRecover from tool failures, model errors, transport errors, and truncation. Docs: s11.en.md.
12s12_task_systemTask SystemAdd structured task records with status, owner, and dependencies. Docs: s12.en.md.
13s13_background_tasksBackground TasksStart, query, and manage long-running background commands. Docs: s13.en.md.
14s14_cron_schedulerCron SchedulerSchedule future tasks and reinject them into the loop when due. Docs: s14.en.md.
15s15_agent_teamsAgent TeamsOrganize multiple agents into teams with roles, inboxes, and messages. Docs: s15.en.md.
16s16_team_protocolsTeam ProtocolsAdd durable request-response protocols for multi-agent collaboration. Docs: s16.en.md.
17s17_autonomous_agentsAutonomous AgentsImplement long-running workers with idle polling and task claiming. Docs: s17.en.md.
18s18_worktree_task_isolationWorktree IsolationUse git worktrees to isolate task execution environments. Docs: s18.en.md.
19s19_mcp_pluginMCP PluginConnect MCP/plugin tools to the same permission and tool-result loop. Docs: s19.en.md.
20s20_tool_refactorTool RefactorRefactor tool registration, routing, dispatch, and macro support. Docs: s20.en.md.
21s21_agent_evaluationAgent EvaluationAdd eval cases, repeatable environments, observable trajectories, deterministic assertions, and LLM-as-a-Judge to the simple s20 agent. Docs: s21.en.md.
FullsfullComplete VersionIntegrate previous chapters into one complete agent harness. Docs: sfull.en.md.

Recommended Reading Order

  1. Run s01_agent_loop and understand the minimal loop: user input, model response, tool call, and tool result.
  2. Read s02_tool_use through s04_subagent to understand tools, planning, and delegation.
  3. Read s05_skill_loading through s08_hook_system to see how a demo becomes an extensible system.
  4. Read s09_memory_system through s14_cron_scheduler to understand state, long-running work, and scheduling.
  5. Read s15_agent_teams through s20_tool_refactor to understand multi-agent collaboration, isolated execution, plugins, and tool routing.
  6. Read s21_agent_evaluation to understand how to determine whether an agent actually completed its task.
  7. Read sfull last to see how the pieces fit together.

Project Structure

text
.
├── Cargo.toml
├── CONTRIBUTING.md
├── s01_agent_loop/
├── s02_tool_use/
├── s03_todo_write/
├── s04_subagent/
├── s05_skill_loading/
├── s06_context_compact/
├── s07_permission_system/
├── s08_hook_system/
├── s09_memory_system/
├── s10_system_prompt/
├── s11_error_recovery/
├── s12_task_system/
├── s13_background_tasks/
├── s14_cron_scheduler/
├── s15_agent_teams/
├── s16_team_protocols/
├── s17_autonomous_agents/
├── s18_worktree_task_isolation/
├── s19_mcp_plugin/
├── s20_tool_refactor/
├── s20_tool_refactor_macros/
├── s21_agent_evaluation/
├── sfull/
└── skills/

Common Commands

Run a chapter:

bash
cargo run -p s03_todo_write

Run the full version:

bash
cargo run -p sfull

Check:

bash
cargo check --workspace

Test:

bash
cargo test --workspace

Format:

bash
cargo fmt --all

Acknowledgements

Some Rust engineering ideas in this project were inspired by bosun-ai/swiftide, especially around hooks and system prompts.

Contributing

Contributions are welcome from people interested in Rust, AI agents, tool use, MCP, and coding agents.

Please read CONTRIBUTING.md before opening an issue or pull request.

Useful contribution areas:

  • Fix unclear or outdated docs.
  • Add explanations, diagrams, or examples.
  • Improve code structure and error handling.
  • Add tests.
  • Connect more models, tools, or MCP servers.
  • Translate docs.

License

This project is licensed under the MIT License.

Please preserve the license information when using, modifying, or distributing this project.

Learn Claude Code RsのMCPを複数のAIモデルで活用

TypingMindはワークスペース単位でMCPツールに接続します。そのため、一度Learn Claude Code Rsに接続すれば、モデルごとに個別に設定することなく、TypingMind内のさまざまなAIモデルで利用できます。 このMCPは、デバイス上のTypingMind MCPコネクタを通じてローカルで動作します。

ローカルコネクタのセットアップガイド

MCPサーバーが、お使いのコンピューター上のローカルファイル、アプリ、非公開リソースにアクセスする必要がある場合は、この方法を使います。

1

MCP設定を開く

TypingMindで「設定」、「詳細設定」、「MCP」の順に進み、「コネクタを設定」を選択してください。

  1. ブラウザでTypingMindを開いてください。
  2. 設定アイコンをクリックしてください。
  3. 「詳細設定」に移動してください。
  4. 「MCP」セクションを開いてください。
  5. 「コネクタを設定」をクリックし、「このデバイス」を選択してください。
「このデバイス」が選択されたTypingMindのMCPコネクタ設定画面
2

コネクタのコマンドを実行

「このデバイス」を選択し、TypingMindからコマンドをコピーしてターミナルで実行してください。MCPの使用中は、プロセスを実行したままにしてください。

  1. TypingMindに表示されるセットアップコマンドをコピーしてください。
  2. macOSではターミナルを、WindowsではWindows Terminalを開いてください。
  3. コマンドを貼り付けて実行してください。
  4. ターミナルで続行の確認を求められた場合は、パッケージのインストールを承認してください。
  5. MCPツールの使用中は、ターミナルウィンドウを開いたまま、プロセスの実行を継続してください。
3

Learn Claude Code Rsをサーバーとして追加

コネクタのステータスが「準備完了」になったら、「サーバーを編集」をクリックし、MCPサーバーの設定を貼り付けてください。

  1. コネクタのステータスが「準備完了」になるまでお待ちください。
  2. 「サーバーを編集」をクリックしてください。
  3. Learn Claude Code RsのMCPサーバー設定を貼り付けてください。
  4. サーバー一覧を保存してください。
  5. コネクタが引き続き使用可能か確認するには、更新してください。
稼働中のサーバーと「サーバーを編集」ボタンが表示されたTypingMindのMCP設定画面
{
  "mcpServers": {
    "learn-claude-code-rs": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

複数のモデルで同じ接続を使用

サーバー一覧を保存し、「プラグイン」を開いてLearn Claude Code RsのMCPツールを有効にしてください。その後、TypingMindで対応するAIモデルを選択し、チャットでツールを使うか、AIエージェントに割り当ててください。

  1. TypingMindの「プラグイン」ページを開いてください。
  2. Learn Claude Code RsのMCPツールを有効にしてください。
  3. チャットを開始し、使用するAIモデルを選択してください。
  4. MCPツールをチャットで使うか、AIエージェントに割り当ててください。
  5. MCPに再接続することなく、必要に応じて別のAIモデルに切り替えられます。
選択したAIモデルと有効なMCPツールを使用したTypingMindのチャット
Learn Claude Code Rsを使ってこのタスクを手伝ってもらえますか?
Learn Claude Code Rs
はい、読みました。
Learn Claude Code Rsで調べた結果をお伝えします。

よくある質問

Learn Claude Code Rs MCPサーバーは何に使いますか?

Learn Claude Code Rsは、対応するAIクライアントを外部ツールやコンテキストに接続するためのMCPサーバーです。TypingMindでは、このMCPサーバーを一度追加するだけで、AIワークスペース内でそのツールを利用できるようになります。

TypingMindでLearn Claude Code Rs MCPを複数のAIモデルと併用できますか?

はい。TypingMindはワークスペース単位でMCPツールに接続するため、モデルごとにMCPサーバーを設定する必要はありません。Claude、ChatGPT、Geminiや、TypingMindで設定したその他のAIモデルでLearn Claude Code Rsを利用できます。

TypingMindでLearn Claude Code Rs MCPを使うメリットは何ですか?

TypingMindは、複数のAIモデル、プロンプト、プラグイン、AIエージェント、APIキー、MCPツールを1つのワークスペースにまとめられる、LLMチャット向けの優れたフロントエンドです。Learn Claude Code Rsを接続すると、TypingMindでチャットのワークフローを整理しながら、お好みのモデルでそのMCPツールを利用できます。

Learn Claude Code Rs MCPをTypingMindに接続するにはどうすればよいですか?

Learn Claude Code RsはTypingMindのローカルMCPコネクタ経由で動作します。MCPサーバーがコンピューター上のローカルファイル、デスクトップアプリ、コマンドラインツール、プライベートリソースにアクセスする必要がある場合に最適です。

TypingMindでLearn Claude Code Rs MCPのどのようなツールを利用できますか?

Learn Claude Code RsはMCP機能を提供しています。TypingMindのプラグインページで有効にすると、チャットで使用したり、AIエージェントに割り当てたりできます。

Learn Claude Code Rs MCPを使うには、APIキーをTypingMindと共有する必要がありますか?

いいえ。TypingMindはローカルファーストの設計で、モデルプロバイダー、APIキー、プロンプト、MCP設定をご自身で管理できます。Learn Claude Code Rsで認証が必要な場合は、接続の作成時に、そのMCPサーバーに必要なヘッダー、OAuth設定、またはローカル設定を追加してください。

関連するMCPサーバー

すべて見る

今すぐ自分専用のAIワークスペースを作成

ニュースレターに登録すると、新機能や今後のプレゼント企画のお知らせが届きます👇