apply_patch tool
기준일: 2026-07-26
난이도: 중급
공식 기준: apply_patch tool
개요
이 페이지는 OpenClaw apply_patch tool 도구(파라미터, 권한, 설정, CLI)를 공식 문서 기준으로 정리합니다.
공식 요약: Apply multi-file patches with the apply_patch tool
도구 가시성은 profile / allow·deny policy / sandbox / channel 권한에 따라 달라집니다. 최신 스키마는 항상 공식 문서를 우선합니다.
공식 문서 기반 상세
아래는 공식 tools/apply-patch 문서를 정리한 내용입니다. 코드 블록, 파라미터 이름, 기본값은 원문 그대로입니다.
Apply file changes using a structured patch format. This is ideal for multi-file
or multi-hunk edits where a single edit call would be brittle.
The tool accepts a single input string that wraps one or more file operations:
*** Begin Patch
*** Add File: path/to/file.txt
+line 1
+line 2
*** Update File: src/app.ts
@@ optional change context
-old line
+new line
*** Delete File: obsolete.txt
*** End Patch
파라미터
input(required): Full patch contents including*** Begin Patchand*** End Patch.
참고
- Patch paths support relative paths (from the workspace directory) and absolute paths.
tools.exec.applyPatch.workspaceOnlydefaults totrue(workspace-contained). Set it tofalseonly if you intentionally wantapply_patchto write/delete outside the workspace directory.- Use
*** Move to:within an*** Update File:hunk to rename files. *** End of Filemarks an EOF-only insert when needed.- Enabled by default for every model. Set
tools.exec.applyPatch.enabled: falseto disable it, or restrict it to specific models withtools.exec.applyPatch.allowModels(accepts raw ids likegpt-5.4or full ids likeopenai/gpt-5.4). - Config lives under
tools.exec.applyPatch.*.
예시
{
"tool": "apply_patch",
"input": "*** Begin Patch\n*** Update File: src/index.ts\n@@\n-const foo = 1\n+const foo = 2\n*** End Patch"
}
관련 문서
Read-only diff viewer for change presentation.
Shell command execution from the agent.
Sandboxed remote Python analysis with xAI.
검증 체크리스트
- 해당 tool이 활성 profile/policy에서 허용되는지 확인
- sandbox / elevated / host 실행 경로 정책을 이해했는지 확인
- 채널·에이전트 권한과 충돌하지 않는지 확인
- 공식 CLI/
--help와 문서 옵션이 버전과 맞는지 확인