{"id":"code-execution","name":"code-execution","summary":"Pythonコードをローカルで実行し、マーケットプレイスのAPIアクセスでまとめて90%+トークンの節約が可能です。","body":"# Code Execution\n\nExecute Python locally with API access. **90-99% token savings** for bulk operations.\n\n## When to Use\n\n- Bulk operations (10+ files)\n- Complex multi-step workflows\n- Iterative processing across many files\n- User mentions efficiency/performance\n\n## How to Use\n\nUse direct Python imports in Claude Code:\n\n```python\nfrom execution_runtime import fs, code, transform, git\n\n# Code analysis (metadata only!)\nfunctions = code.find_functions('app.py', pattern='handle_.*')\n\n# File operations\ncode_block = fs.copy_lines('source.py', 10, 20)\nfs.paste_code('target.py', 50, code_block)\n\n# Bulk transformations\nresult = transform.rename_identifier('.', 'oldName', 'newName', '**/*.py')\n\n# Git operations\ngit.git_add(['.'])\ngit.git_commit('feat: refactor code')\n```\n\n**If not installed:** Run `~/.claude/plugins/marketplaces/mhattingpete-claude-skills/execution-runtime/setup.sh`\n\n## Available APIs\n\n- **Filesystem** (`fs`): copy_lines, paste_code, search_replace, batch_copy\n- **Code Analysis** (`code`): find_functions, find_classes, analyze_dependencies - returns METADATA only!\n- **Transformations** (`transform`): rename_identifier, remove_debug_statements, batch_refactor\n- **Git** (`git`): git_status, git_add, git_commit, git_push\n\n## Pattern\n\n1. **Analyze locally** (metadata only, not source)\n2. **Process locally** (all operations in execution)\n3. **Return summary** (not data!)\n\n## Examples\n\n**Bulk refactor (50 files):**\n```python\nfrom execution_runtime import transform\nresult = transform.rename_identifier('.', 'oldName', 'newName', '**/*.py')\n# Returns: {'files_modified': 50, 'total_replacements': 247}\n```\n\n**Extract functions:**\n```python\nfrom execution_runtime import code, fs\n\nfunctions = code.find_functions('app.py', pattern='.*_util$')  # Metadata only!\nfor func in functions:\n    code_block = fs.copy_lines('app.py', func['start_line'], func['end_line'])\n    fs.paste_code('utils.py', -1, code_block)\n\nresult = {'functions_moved': len(functions)}\n```\n\n**Code audit (100 files):**\n```python\nfrom execution_runtime import code\nfrom pathlib import Path\n\nfiles = list(Path('.').glob('**/*.py'))\nissues = []\n\nfor file in files:\n    deps = code.analyze_dependencies(str(file))  # Metadata only!\n    if deps.get('complexity', 0) > 15:\n        issues.append({'file': str(file), 'complexity': deps['complexity']})\n\nresult = {'files_audited': len(files), 'high_complexity': len(issues)}\n```\n\n## Best Practices\n\n✅ Return summaries, not data\n✅ Use code_analysis (returns metadata, not source)\n✅ Batch operations\n✅ Handle errors, return error count\n\n❌ Don't return all code to context\n❌ Don't read full source when you need metadata\n❌ Don't process files one by one\n\n## Token Savings\n\n| Files | Traditional | Execution | Savings |\n|-------|-------------|-----------|---------|\n| 10 | 5K tokens | 500 | 90% |\n| 50 | 25K tokens | 600 | 97.6% |\n| 100 | 150K tokens | 1K | 99.3% |","author":"@mhattingpete","ownerProfile":null,"authorContacts":null,"sourceUrl":"https://github.com/mhattingpete/claude-skills-marketplace/tree/main/code-operations-plugin/skills/code-execution","license":"Apache-2.0","category":"document","lang":"en","tokens":746,"stars":0,"calls30d":3,"claimed":false,"visibility":"public","origin":"crawler","version":"0.1.0","createdAt":"2026-08-22","updatedAt":"2026-08-22","files":[{"path":"examples/bulk_refactor.py","size":737,"sha256":"533620cb9c2b91d8ab27619a6137a42b599956456ec508ce829f4f485c1ef30a"},{"path":"examples/codebase_audit.py","size":2234,"sha256":"5faecc0dcfeb355ecee413e1c65c80c4991861ee3e1c44c3da0de9831883c3a4"},{"path":"examples/extract_functions.py","size":1183,"sha256":"ab5df39355f98de9d89876d8b7815335ab261e32eb9d1c57eea555e12dec6573"}],"requires":{"mcp":[],"tools":[]},"safety":{"flags":[],"scannedAt":"2026-08-22","hasScripts":true,"networkEndpoints":[]}}