본문으로 건너뛰기
Skillpedia
일반 코딩7.8k · #13030

working-directory-resolution

하는 일

이 스킬은 명령을 잘못된 폴더에서 실행해서 생기는 파일 오류를 피하는 방법을 AI 에이전트에게 보여 줍니다. 파일은 있는데 에이전트가 찾을 수 없다고 보고하는 사람을 위한 스킬입니다.

사용하는 경우

  • ✓파일 읽기가 파일이 있는데도 찾을 수 없음 오류로 실패할 때.
  • ✓샌드박스가 작업에서 언급된 파일을 찾지 못할 때.
  • ✓셸 명령이 있어야 할 파일을 없다고 보고할 때.

스킬 링크

https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/working-directory-resolution/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/HKUDS/AgentPilot/blob/main/openspace/benchmarks/gdpval/skills/working-directory-resolution/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“에이전트가 제 config.json이 없다고 합니다. 작업 공간에는 있는 것이 보입니다. 폴더 문제를 고치고 파일을 읽어 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트는 각 셸 명령 앞에 대상 폴더로 이동하는 cd를 붙여, 모든 명령이 올바른 위치에서 실행되도록 합니다. 이렇게 하면 작업 폴더와 파일 위치가 어긋나는 문제가 사라집니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Working Directory Resolution Pattern

Many file operation failures occur because the tool's current working directory doesn't match where the target files are located. This skill provides a reliable pattern for resolving such issues.

Problem Symptoms

File operations fail with errors like:

  • "File not found" or "No such file or directory"
  • "Permission denied" (when path is actually relative)
  • Tools returning empty results for files that should exist

These failures often occur even when files are present in the workspace—the working directory context is simply wrong.

Solution

Always explicitly set the working directory before file operations by prepending cd to your shell commands.

Implementation Pattern

Basic Syntax

cd /path/to/target/directory && your-command-here

With run_shell

run_shell(command="cd /workspace/project && cat config.json")

Multiple Operations in Same Directory

cd /workspace/project && ls -la && cat README.md && python script.py

Conditional Directory Change

cd /workspace/project 2>/dev/null && cat file.txt || echo "Directory not found"

When to Apply

Use this pattern when:

  • read_file fails to locate an existing file
  • execute_code_sandbox can't find referenced files
  • Shell commands report missing files that should exist
  • File paths work in some contexts but not others
  • You're unsure of the tool's current working directory

Best Practices

  1. Use absolute paths when possible

    cd /workspace/project/src && python main.py
    
  2. Combine related operations to avoid repeated cd calls

    cd /workspace/project && ./build.sh && ./test.sh
    
  3. Verify directory exists before operations

    [ -d /workspace/project ] && cd /workspace/project && ls
    
  4. For scripts, set working directory at the start

    #!/bin/bash
    cd "$(dirname "$0")" || exit 1
    # Rest of script runs from script's directory
    

Common Pitfalls

Issue Wrong Approach Correct Approach
Relative paths cat config.json cd /workspace && cat config.json
Assumed cwd python script.py cd /workspace && python script.py
Multiple dirs cd dir1; cd dir2; cmd cd dir1/dir2 && cmd

Fallback Strategy

If cd also fails:

  1. Use pwd to check current directory
  2. Use find or ls -R to locate files
  3. Verify the path structure with ls -la /path/to/check
pwd && find /workspace -name "target_file.txt" 2>/dev/null

This pattern is especially valuable when tools like execute_code_sandbox or read_file fail but run_shell with explicit directory context succeeds.

자주 묻는 질문

이것이 왜 파일 없음 오류를 고치나요?

대부분의 그런 오류는 명령이 파일이 있는 곳과 다른 폴더에서 실행되어 생기기 때문이라고 스킬은 설명합니다.

한 폴더에서 여러 명령을 실행할 수 있나요?

네, 스킬은 한 번의 cd 뒤에 명령을 이어서 모두 같은 폴더에서 실행하는 방법을 보여 줍니다.

폴더가 없으면 어떻게 하나요?

폴더를 찾을 수 없을 때 메시지를 출력하는 조건문 형태를 스킬이 보여 줍니다.

상세 정보

작성자의 원본 설명

Resolve file access failures by changing to the correct working directory before command execution

repo: HKUDS/AgentPilot

인기도

GitHub 스타
7.8k
순위
#13030
라이선스
MIT
업데이트
2026. 11. 1.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬