프롬프트 도감 › No.2826
파일 경로 안전 조회 규칙
Safe File Path Anchor
AI가 대화 중에 언급된 파일 경로를 현재 작업 폴더와 기록에 맞춰 안전하게 찾아내는 검증 규격을 다뤄요. 엉뚱한 파일 수정을 방지하고 정확한 파일만 열도록 안내해요.
이럴 때 도구 호출 검증, 파일 안전성 보장, 시스템 개발
도구 AI
프롬프트
<!-- name: "Data: SDK read_file anchor as_written kind" description: "Schema description for the read_file anchor's as_written kind, which resolves a path copied from Claude's replies against the cwd, git root, working directories, and previously read or written files, and treats ambiguous, out-of-scope, or unresolved paths as final refusals" ccVersion: "2.1.307" --> For a path copied from one of Claude's replies, which may be relative to the cwd of an earlier moment or to the root of the repository, or may lack its leading directories. Send it only to a session whose newest system/init lists the capability read_file_as_written_v1, and send the text without a line suffix (`:12`, `#L12`) or URL scheme. The session tries the text against the live cwd, the git root above that and its working directories. If no file is there, it looks below them for a file whose path ends in the text, among the paths its file state has held: those the file tools of the main conversation have read or written since the process started, or in the transcript it started from, and what a host has seeded or staged. A file that only a sub-agent touched is not among them, nor one that only a shell command touched, unless the command did nothing but print single files plainly (`cat f`, `head f`, `sed -n 1,9p f` and the like, or a lone `grep` that matches), with no pipe or redirect. It reads a file only when exactly one fits or, of several that fit a directory, exactly one is among those paths. The response's `absPath` names the file read. Show that path: the file can be a namesake of the one meant. A text that is `~` or starts with `~/`, a text that fits no file or several, a file found in none of the folders of `within`, and a look-up that could not be finished are refused. From such a session a refusal is final for the `within` it was asked with: asking again with a directory of the client's own choosing would turn "two files fit" into "the first one wins". A CLI that has `anchor` but predates this kind refuses it.
팁
- 상대 경로와 절대 경로가 섞이지 않도록 기준 경로를 확인해요
- 존재하지 않거나 모호한 경로는 안전하게 거부하도록 설정해요
출처
권리: MIT; Piebald-AI/claude-code-system-prompts; 원문 출처 링크 참조. 수정·번역 여부는 카드 메타 참조.