跳到正文
cccskills
免费在 GitHub 公开

working-directory-resolution

Troubleshoot file access failures caused by commands running in the wrong folder. Set the working directory explicitly before file operations, check directory paths, and locate files when relative paths resolve differently across tools.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

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

查看安装方法

适用场景

  • Troubleshooting missing-file errors for existing files
  • Running scripts from the intended project folder
  • Checking paths that behave differently across tools

包含的文件(2)

  • SKILL.md2.9 KB
  • .skill_id42 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

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

IssueWrong ApproachCorrect Approach
Relative pathscat config.jsoncd /workspace && cat config.json
Assumed cwdpython script.pycd /workspace && python script.py
Multiple dirscd dir1; cd dir2; cmdcd 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.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Incremental audio production with duration mismatch handling, adaptive stem extension, and pre-mix alignment verification

中文简介正在准备中。当前显示原文说明。

HKUDS/OpenSpace77562026年8月13日 更新

Incremental audio production with duration alignment handling, per-stem verification, and adaptive extension strategies

中文简介正在准备中。当前显示原文说明。

HKUDS/OpenSpace77562026年8月13日 更新

Build serverless endpoints that relay external API requests for a dashboard while keeping API keys on the server. Includes Vercel examples for input checks, caching, cross-origin access, and consistent JSON responses.

中文简介正在准备中。当前显示英语简介。

  • Connect a dashboard to external APIs without exposing API keys
  • Create endpoints for stock quotes and news
  • Standardize API responses and error handling
HKUDS/OpenSpace77562026年8月13日 更新

End-to-end audio production workflow with stems, effects, archiving, and verification

中文简介正在准备中。当前显示原文说明。

HKUDS/OpenSpace77562026年8月13日 更新

Keep document creation moving when web searches and page retrieval repeatedly fail. The skill preserves the original task, uses the model’s existing knowledge, and clearly identifies information that could not be checked against external sources.

中文简介正在准备中。当前显示英语简介。

  • Continue drafting after repeated web retrieval failures
  • Preserve task requirements during network errors
  • Mark information that could not be externally verified
HKUDS/OpenSpace77562026年8月13日 更新

Fallback pattern for executing Python code when execute_code_sandbox fails

中文简介正在准备中。当前显示原文说明。

HKUDS/OpenSpace77562026年8月13日 更新

查看 HKUDS 的全部技能

报告此技能的问题