with one click
add-tool
// Guide for adding a new tool to OhMyCode. Use when user wants to create a custom tool.
// Guide for adding a new tool to OhMyCode. Use when user wants to create a custom tool.
Run OhMyCode benchmarks — score any provider/model with token tracking. Use when user wants to benchmark, evaluate, test performance, or compare models.
Generate high-quality tests for OhMyCode modules. Use when user wants to create, add, or generate tests for a module or file.
Run tests and analyze results for OhMyCode. Use when user wants to run, check, or verify tests — or after any code change.
Guide for debugging OhMyCode issues. Use when user reports errors, unexpected behavior, or connection problems.
Guide for adding a new feature to OhMyCode. Use when user wants to add functionality that goes beyond existing extension points (tools/providers). Always start by reading docs/DEVELOPMENT_GUIDE.md.
Guide for adding a new LLM provider to OhMyCode. Use when user wants to connect a new AI model backend.
| name | add-tool |
| description | Guide for adding a new tool to OhMyCode. Use when user wants to create a custom tool. |
Create a new tool that the AI assistant can use during conversations.
docs/DEVELOPMENT_GUIDE.md for project conventionsohmycode/tools/base.py to understand Tool, ToolContext, ToolResult, @register_toolohmycode/tools/bash.py) as referenceAsk the user:
sql_query, docker_run)Copy the template from templates/tool_template.py to ohmycode/tools/<tool_name>.py.
Fill in:
name, description, parameters, concurrent_safe class attributesexecute() method with the actual logicCreate tests/tools/test_<tool_name>.py:
import pytest
from ohmycode.tools.base import ToolContext
from ohmycode.tools.<tool_name> import <ToolClass>
@pytest.fixture
def ctx(tmp_path):
return ToolContext(mode="auto", agent_depth=0, cwd=str(tmp_path), is_sub_agent=False)
@pytest.mark.asyncio
async def test_<tool_name>_basic(ctx):
tool = <ToolClass>()
result = await tool.execute({"param": "value"}, ctx)
assert not result.is_error
assert "expected" in result.output
python3 -m pytest tests/tools/test_<tool_name>.py -v # New tests pass
python3 -m pytest tests/ -v # No regressions
ohmycode -p "Use the <tool_name> tool to ..." --mode auto
git add ohmycode/tools/<tool_name>.py tests/tools/test_<tool_name>.py
git commit -m "feat(tools): add <tool_name> tool"
ohmycode/tools/ — auto-imported, no other files need to change@register_tool decorator on the classexecute() must be async and return ToolResultexecute() — return ToolResult(is_error=True) instead@register_tool decorator → tool won't be availableToolResult(is_error=True) → crashes the loopconcurrent_safe = True on tools with side effects → race conditionsohmycode/tools/ first