Skip to main content
skill CX Codex

patterns — Claude Code skill: what it does, how to install

Design pattern index for the Langroid multi-agent framework. Guides agents on tool handling, task lifecycle control, and external MCP setups.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add pchalasani/claude-code-tools --skill patterns -a claude-code
Open on GitHub

What patterns does

This skill acts as a curated index of architectural patterns for building multi-agent setups in Langroid. It organizes design patterns into four categories: core agent tasks, stateful tool handlers, task control rules, and external integrations.

Inside are references to code implementations covering direct ToolMessage returns, stateful handlers tracking API retries, and output validation using AgentDoneTool. It also provides blueprints for parallel execution using run_batch_tasks() with fresh message histories, as well as console cleanup via the quiet_mode() manager. Another section details connecting stdio-based MCP servers using the @mcp_tool decorator or get_tools_async().

The patterns rely strictly on Langroid constructs such as TaskConfig and DoneTool. Without the Langroid library in your environment, these blueprints have no target implementation.

What it helps with

  • validate agent tool outputs against context before task completion
  • run concurrent multi-agent batch tasks with state isolation
  • connect external MCP tools to Langroid agents via stdio
  • mute agent streaming logs during workflow execution

Example prompts for the agent

  • Show the Langroid pattern for stateful tool handlers with retry counters
  • How do I terminate a Langroid task only when a specific tool runs?
  • Give me an example of connecting Claude Code MCP tools to a Langroid agent

How to install patterns

1Skills CLI (Vercel)

npx skills add pchalasani/claude-code-tools --skill patterns -a claude-code

2Manually: put the files in place

~/.claude/skills/patterns/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/patterns/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about patterns

How to install patterns in Claude Code?

Run npx skills add pchalasani/claude-code-tools --skill patterns -a claude-code. The skill file will be placed in ~/.claude/skills/patterns/SKILL.md.

What does the patterns skill do?

It indexes Langroid framework design patterns and directs the model to practical examples for task controls, tool validation, and MCP integration.

How does the skill control task termination?

It details how to configure done_sequences inside TaskConfig. You can exit immediately when a tool fires or wait until the agent finishes handling it.

Source text

SKILL.md · MIT
---
name: patterns
description: Design patterns for the Langroid multi-agent LLM framework. Covers
  agent configuration, tools, task control, and integrations.
---

# Langroid Patterns

## Instructions

Below is an INDEX of design patterns organized by category. Each item describes
WHAT you might want to implement, followed by a REFERENCE to a document with
a complete code example.

Scan this index to find patterns matching your needs, then consult the
corresponding document.

---

## Agent & Task Basics

1. **Task Returns Tool Directly**

   Create a Langroid Agent equipped with a single Tool (a ToolMessage), and wrap
   it in a Task so that running the task returns that ToolMessage directly. Use
   this pattern when you want a simple LLM agent that returns a structured
   response.

   - Reference: `./task-return-tool.md`

---

## Tool Handlers

2. **Stateful Handler on Agent**

   Define a STATEFUL tool handler as a METHOD on the agent (not inside the
   ToolMessage). Use this pattern when: (a) the tool handler needs to execute
   external operations (API calls, database queries, file I/O), (b) you need to
   track state across retries (e.g., failure counter), (c) the handler needs
   access to agent-level resources (connections, configs), or (d) you want
   Langroid to automatically loop errors back to the LLM for self-correction.
   The method name must match the `request` field of the ToolMessage. Return a
   string for errors (LLM sees it and can retry), or DoneTool(content=result)
   to terminate successfully.

   - Reference: `./agent-tool-handler-with-state.md`

3. **Handler with Validation**

   Validate tool output against agent state before accepting it. Use this
   pattern when: (a) the LLM's tool output must preserve certain content from
   the input (e.g., placeholders, required fields), (b) you want automatic
   retry if validation fails, (c) you need to compare tool output against
   context the LLM received. Define a handler method on a custom agent class
   that stores the input context as state, validates the tool output, and
   returns an error string for retry or AgentDoneTool for success (note: use
   AgentDoneTool, NOT DoneTool). Use `done_sequences=["T[ToolName], A"]` so the
   handler runs before task termination.

   - Reference: `./agent-handler-validation-with-state.md`

---

## Task Control

4. **Terminate on Specific Tool**

   Terminate a Task only when a SPECIFIC tool is called. Use
   `TaskConfig(done_sequences=["T[ToolName]"])` to exit immediately when that
   tool is emitted, or `TaskConfig(done_sequences=["T[ToolName], A"])` to exit
   after the tool is emitted AND handled by the agent. Use this when an agent
   has multiple tools but you only want one specific tool to trigger task
   termination.

   - Reference: `./done-sequences-specific-tool.md`

5. **Batch Processing**

   Run the SAME task on MULTIPLE inputs concurrently using `run_batch_tasks()`.
   Use this pattern when: (a) you need to process many items with the same
   agent/task logic, (b) you want parallelism without manual asyncio/threading,
   (c) you need state isolation between items (each gets a cloned agent with
   fresh message history), (d) you want to avoid connection exhaustion from
   creating too many agents manually. Each item gets a cloned task+agent, runs
   independently, results collected in order. Supports batch_size for
   concurrency limiting.

   - Reference: `./run-batch-tasks.md`

---

## Integration & Output

6. **MCP Tools Integration**

   Enable a Langroid agent to use MCP (Model Context Protocol) tools from an
   external MCP server like Claude Code. Use this pattern when: (a) you want
   your agent to use file editing tools (Read, Edit, Write) from Claude Code,
   (b) you need to connect to any MCP server via stdio transport, (c) you want
   to enable ALL tools from an MCP server or just SPECIFIC tools selectively,
   (d) you want to customize/post-process MCP tool results before returning to
   the LLM. Uses `@mcp_tool` decorator for specific tools or `get_tools_async()`
   for all tools.

   - Reference: `./mcp-tool-integration.md`

7. **Quiet Mode**

   Suppress verbose Langroid agent output (streaming, tool JSON, intermediate
   messages) while showing your own custom progress messages. Use this pattern
   when: (a) you want clean CLI output showing only milestone events, (b) you're
   running a multi-step workflow and want to show progress without agent noise,
   (c) you need thread-safe output control. Use `quiet_mode()` context manager
   to wrap agent task.run() calls, then print your own messages outside the
   context.

   - Reference: `./quiet-mode.md`

© pchalasani · MIT · pchalasani/claude-code-tools

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set15

code-walk-thru The skill makes the agent open files in your editor one at a time, at the exact line, so you can follow a code walkthrough or review its changes. CX Codex +1 ★ 2,021repo stars voice-update Speaks a short audio summary of completed tasks using pocket-tts. Useful when monitoring background runs without watching the screen. CX Codex +1 ★ 2,021repo stars tmux-cli This skill lets an agent work with CLI agents and scripts in other tmux panes. Use it for shell commands, exit-code checks, and pane-to-pane communication. CX Codex +1 ★ 2,021repo stars msg This skill hands your agent a msg CLI for talking to other Claude and Claude sessions, reading incoming messages and coordinating across tmux panes. CX Codex +1 ★ 2,021repo stars add-pattern Save Langroid design patterns for later use with a catalog entry and a separate implementation document containing code examples. CX Codex +1 ★ 2,021repo stars dynamic-workflow Coordinates durable JavaScript workflows to run headless Codex agents in parallel. Helpful for batch item audits, multi-stage pipelines, and long tasks. CX Codex +1 ★ 2,021repo stars recover-context This skill retrieves the last task from a parent session, along with its status, decisions, and pending work. Use it when continuing from a session lineage. CX Codex +1 ★ 2,021repo stars jev-prose The skill runs your draft through the jev-prose CLI, gets a report on narrow AI-writing patterns, and revises from that feedback. Useful while drafting paragraphs. CX Codex +1 ★ 2,021repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor