スキル一覧に戻る
gradion-ai

saving-codeacts

by gradion-ai

saving-codeactsは、other分野における実用的なスキルです。複雑な課題への対応力を強化し、業務効率と成果の質を改善します。

119🍴 8📅 2026年1月20日
GitHubで見るManusで実行

SKILL.md


name: saving-codeacts description: 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.

Saving Code Actions as Reusable Tools

Save executed Python code as a tool for later reuse.

Package Structure

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 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.py inside run()
  • Include comprehensive docstring
  • Export OutputModel and run in 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 mcptools or gentools packages
  • 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

スコア

総合スコア

80/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

+5
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

レビュー

💬

レビュー機能は近日公開予定です