lauren-framework/lauren-ai/building-tools

Claude Code and agent skill by lauren-framework/lauren-ai

Trust tier 3
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
Source check pending

Checking that the SKILL.md file is still in the repository.

Creates tools for lauren-ai agents using @tool() on async functions or classes. Use when implementing a @tool() function or class, working with ToolContext for DI injection, adding caching, HITL approval, or using built-in skills like WebSearchTool, HttpFetchTool, or CodeExecutionTool.

Install

npx vskill@latest install lauren-framework/lauren-ai/building-tools

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as lauren-framework/lauren-ai/building-tools.

Use codemap find "SymbolName" to locate any symbol before reading — it gives
exact file + line range and is faster than grep across the whole repo.

Building Tools with lauren-ai

Critical rule — tool annotations must resolve

`from __future__ import annotations` is supported, but every type used by `@tool()` must resolve when schema generation runs.

@tool() resolves annotations when it builds the JSON schema. Future annotations are supported, but unresolved forward references and circular imports in function-form tool files still break schema generation.

A safe reminder comment is:

python
# @tool() resolves parameter annotations when this module is imported.
# Keep tool signature types importable and avoid unresolved forward refs.

Quick start — function-form tool

python
from lauren_ai import tool
@tool()
async def get_price(item: str) -> dict:
"""Look up an item's current price.
Args:
item: Product name to look up.
"""
return {"item": item, "price": 9.99}

Attach it to an agent:

python
from lauren_ai import agent, use_tools
@agent(model="claude-opus-4-6", system="You are a helpful shop assistant.")
@use_tools(get_price)
class ShopAgent: ...

Quick start — class-form tool

Use a class when the tool needs injected dependencies. The method must be named run() — not __call__(). The @tool() decorator looks for run; a __call__ is silently ignored and the decorator will raise ValueError.

python
from lauren_ai import tool, ToolContext
@tool()
class SendEmailTool:
"""Send an email to a recipient.
Args:
to: Recipient email address.
subject: Email subject line.
body: Email body text (plain text).
"""
def __init__(self, smtp_client: SmtpClient) -> None:
self._smtp = smtp_client
async def run(
self,
to: str,
subject: str,
body: str,
ctx: ToolContext | None = None,
) -> dict:
await self._smtp.send(to=to, subject=subject, body=body)
return {"sent": True, "to": to}

ToolContext — DI injection, not LLM input

ToolContext is never included in the JSON schema sent to the LLM. ToolExecutor injects it automatically at call time. Use it to:

  • Access the agent's AgentContext via ctx.agent_context
  • Read the authenticated user identity from ctx.execution_context.request.state
  • Identify the current turn number via ctx.turn
python
@tool()
async def whoami(ctx: ToolContext | None = None) -> dict:
"""Return the authenticated user's ID.
(No additional parameters — all identity comes from context.)
"""
if ctx is None or ctx.execution_context is None:
return {"user_id": None}
state = getattr(ctx.execution_context.request, "state", None)
user_id = state.get("user_id") if state else None
return {"user_id": user_id}

The generated schema contains zero parameters:

json
{
"name": "whoami",
"input_schema": {"type": "object", "properties": {}, "required": []}
}

Schema generation rules

Python annotationJSON Schema typeRequired?
str"string"yes (unless Optional)
int / float"number"yes (unless Optional)
bool"boolean"yes (unless Optional)
dict"object"yes (unless Optional)
list"array"yes (unless Optional)
Optional[T] / `T \None`type Tno
ctx: ToolContext / `ctx: ToolContext \None = None`—excluded entirely
parameter with default valuetype Tno

Parameter descriptions come from the Args: section of the Google-style docstring. Always document every parameter.


Safety invariants

RuleWhy
`run()` not `__call__()`@tool() looks for run; a __call__ method is silently ignored
Resolvable tool annotationsFuture annotations are supported, but @tool() still needs every referenced type to resolve when it builds the schema
Decorate with `@tool()` (parentheses required)Bare @tool raises DecoratorUsageError
Never use LLM-supplied identityRead from ctx.execution_context.request.state — see security.md
Always return a `dict`LLM receives the JSON-serialised return value as the tool result

Reference files

FileContents
tools.mdFull reference: schema rules, HITL approval, caching, on_tool_result hook, built-in skills
../securing-agents/security.mdSecure tool patterns using ToolContext.execution_context
../building-agents/agents.md@agent, lifecycle hooks, attaching tools via @use_tools

Security

  • Security scanPassed, 90 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/lauren-framework/lauren-ai/building-tools/badge)](https://verified-skill.com/skills/lauren-framework/lauren-ai/building-tools)

Something wrong with this skill or its page? Tell us.