Agent skill
saving-codeacts
Save executed Python code as reusable tools in the gentools package. Use when preserving successful code executions for later reuse. Covers creating package structure (api.py, impl.py), defining Pydantic output models, and implementing the run() interface.
Install this agent skill to your Project
npx add-skill https://github.com/gradion-ai/freeact/tree/main/freeact/agent/config/templates/skills/saving-codeacts
SKILL.md
Saving Code Actions as Reusable Tools
Save executed Python code as a tool for later reuse.
Package Structure
{generated_rel_dir}/gentools/<category>/<tool>/
├── __init__.py # Empty file
├── api.py # Public interface with structured models
└── impl.py # Implementation details
Procedure
1. Create Package Directory
mkdir -p {generated_rel_dir}/gentools/<category>/<tool>
Create empty __init__.py files in both <category> and <tool> directories.
2. Define Tool API (api.py)
from __future__ import annotations
from pydantic import BaseModel, Field
class OutputModel(BaseModel):
"""Description of output."""
field: type = Field(..., title="Description")
def run(param1: type, param2: type = default) -> OutputModel:
"""Tool description.
Args:
param1: Description
param2: Description (default: value)
Returns:
OutputModel with structured data
"""
from .impl import implementation_function
return implementation_function(param1, param2)
Requirements:
- Define Pydantic models for structured output
- Create
run()function with typed parameters - Use lazy import from
impl.pyinsiderun() - Include comprehensive docstring
- Export
OutputModelandrunin{generated_rel_dir}/gentools/<category>/<tool>/__init__.py:
from .api import OutputModel, run
__all__ = ["OutputModel", "run"]
3. Implement Details (impl.py)
from __future__ import annotations
from mcptools.<category>.<tool> import Params, run_parsed
from .api import OutputModel
def implementation_function(param1: type, param2: type) -> OutputModel:
"""Implementation description."""
# Use tools from mcptools or gentools packages
result = run_parsed(Params(...))
# Transform and return structured output
return OutputModel(field=result.data)
Requirements:
- Import tools from
mcptoolsorgentoolspackages - Import models from
api.py - Return structured models defined in
api.py
4. Test the Tool
from gentools.<category>.<tool>.api import run
result = run(param1=value1, param2=value2)
print(result)
Best Practices
- Separation: Keep API clean; hide complexity in implementation
- Type Safety: Use Pydantic models for all outputs
- Modularity: Break complex logic into smaller functions
- Defaults: Provide sensible defaults for optional parameters
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
freeact-interaction
Interact with freeact agent via tmux for testing
output-parsers
Generate output parsers for mcptools with unstructured return types. Use when a tool returns raw strings or Result models with single str fields and needs structured ParseResult output. Covers testing tools, identifying parseable structures, extending modules with ParseResult models, and creating parser implementations.
task-planning
Structured task planning workflow with user feedback loops. Use when the user explicitly requests planning (e.g., "make a plan", "plan first", "create a plan"). Covers creating plans with actionable steps, iterating based on feedback, saving confirmed plans, and executing step-by-step with progress tracking.
codeact
Generate and execute code for acting with Python tools. Activate when user explicitly requests to "use the codeact skill" or similar phrases.
Ethical Hacking Methodology
This skill should be used when the user asks to "learn ethical hacking", "understand penetration testing lifecycle", "perform reconnaissance", "conduct security scanning", "exploit vulnerabilities", or "write penetration test reports". It provides comprehensive ethical hacking methodology and techniques.
Red Team Tools and Methodology
This skill should be used when the user asks to "follow red team methodology", "perform bug bounty hunting", "automate reconnaissance", "hunt for XSS vulnerabilities", "enumerate subdomains", or needs security researcher techniques and tool configurations from top bug bounty hunters.
Didn't find tool you were looking for?