Refactor builtin tool

From fritzprix/libr-agent · View interactive version

Refactor builtin tool is an AI agent skill from the GitHub repository fritzprix/libr-agent. Guide and principles for refactoring built-in MCP tools in LibrAgent. Use this skill when reviewing, refactoring, or optimizing existing built-in tools to reduce AI cognitive load, eliminate internal callback tool exposure, consolidate redundant tools, and ensure strict state synchronization across

How to use this skill

Skill file

Built-in Tool Refactoring Guide

When to Use This Skill

Use this skill when:

Core Design Principles

1. Context Economy & Cognitive Load

AI agents operate within strict context limits. Every exposed tool consumes tokens and attention.

2. Consolidation & Auto-Switching

Reduce the sheer number of tools by combining highly similar operations into a single tool with smart, data-driven behavior.

3. Strict Synchronization & State Integrity

Data integrity must be guaranteed at the backend level.

4. Don't Repeat Yourself (DRY) in Integration

Built-in tools should leverage central architectures.

5. Cross-Platform UX Considerations

Refactoring Workflow

  1. Audit tools.rs: Identify all tools exported via all_tools(). Remove any tool that is strictly an internal callback.
  2. Review Descriptions: Condense verbose descriptions in MCPTool definitions.
  3. Consolidate Sibling Tools: Check for tools with similar prefixes (e.g., read_foo, read_bar) and combine them if their core intent is identical.
  4. Check Handlers: Ensure handlers use central service functions instead of duplicating connection/execution logic.
  5. Verify State Updates: Ensure any DB mutations happen _after_ successful synchronous verification.
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.