humanerd-drew/opencode-drewgent/python-large-file-patch-drewgent
Claude Code and agent skill by humanerd-drew/opencode-drewgent
- community
Checking that the SKILL.md file is still in the repository.
How to patch large Python files in the {{AGENT_NAME}} codebase. Covers the dual-file layout (runtime ~/.{{AGENT_NAME_LOWER}}/agent/ vs source ~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/), diagnose-fallback when direct patch fails, and the copy-sync protocol to keep both copies aligned.
Install
npx vskill@latest install humanerd-drew/opencode-drewgent/python-large-file-patch-drewgentSKILL.md
The same SKILL.md was published earlier as humanerd-drew/opencode-drewgent/python-large-file-patch-drewgent.
Skill: Patching Large Python Files in {{AGENT_NAME}}
When to Use
When you need to edit a specific function or code block inside a large Python file (500+ lines) in the {{AGENT_NAME}} codebase (signal_processor.py, run_agent.py, gateway/run.py, etc.), and direct patch fails due to text pattern mismatch.
The Problem
patch relies on exact string matching. Large files with complex docstrings (especially with newlines and special characters) often don't match what you expect from reading partial snippets. You get "old_string not found" even when the function exists.
CRITICAL: Dual-File Layout (Runtime vs Source)
{{AGENT_NAME}} has two copies of the agent code:
| Copy | Path | Purpose | |
|---|---|---|---|
| Runtime | ~/.{{AGENT_NAME_LOWER}}/agent/ | What Python actually imports at runtime | |
| Source | ~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/agent/ | Git-tracked development copy |
When you patched a file in the source/ copy but nothing changed, it's because Python loaded from ~/.{{AGENT_NAME_LOWER}}/agent/ instead. The two copies can and do diverge.
Patching Protocol
- Identify which copy is live before editing:
``python python3 -c "import module_name; print(module_name.__file__)" ``
- Patch the runtime copy first (
~/.{{AGENT_NAME_LOWER}}/agent/...) — that's where the effect is immediate.
- Sync the source copy after the fix to keep them aligned:
``bash cp ~/.{{AGENT_NAME_LOWER}}/agent/patched_file.py ~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/agent/patched_file.py ``
- Verify with an import and test call before declaring done.
Solution: Python Patch Script with Diagnostic Output
When patch fails, use execute_code to:
- First read the file and locate the exact text with
inoperator - Print diagnostics so you know exactly what to match
- Apply with
content.replace(old, new, 1)— the1limit prevents accidental multi-match - Write back and verify
Key Rules
- Always use `1` in `replace(old, new, 1)` — prevents replacing the same pattern multiple times accidentally
- Search before patching — use
inoperator to confirm exact text exists before replacing - Use `re.DOTALL` for multi-line matches — docstrings and indented blocks span lines
- Print `repr()` of found text — reveals hidden characters (
\n,\r, trailing spaces) that break exact matching - Match from unique anchor to unique anchor — not just the function header alone; include enough context to be unique
- Patch both copies — runtime first, then sync source. Patching only the source has no effect.
{{AGENT_NAME}} File Paths (both copies)
Runtime (active) — ~/.{{AGENT_NAME_LOWER}}/:
agent/auxiliary_client.py(~2127 lines)agent/title_generator.pyagent/signal_processor.pygateway/run.py(~8700 lines)run_agent.py{{AGENT_NAME_LOWER}}_cli/auth.py
Source (git-versioned) — ~/.{{AGENT_NAME_LOWER}}/source/{{AGENT_NAME_LOWER}}-agent/:
agent/auxiliary_client.pyagent/signal_processor.pyagent/prompt_builder.pyrun_agent.pygateway/run.py
Anti-Patterns
- Don't use
catorheadto read files before patching — useread_filewith offset/limit - Don't patch only the source copy and expect the runtime to change — patch both
- Don't try to match just
"""docstring"""alone — docstrings often have newlines and vary in wording - Don't use
replace_all=Trueunless you intentionally want to replace every occurrence
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
- SKILL.md in the repositoryCheckingskills/software-development/python-large-file-patch-drewgent/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
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
[](https://verified-skill.com/skills/humanerd-drew/opencode-drewgent/python-large-file-patch-drewgent)