Agentic Research

Working directory

Also: 工作目錄 · 目前目錄 · 當前目錄 · pwd · current directory

The folder you are currently "standing in": any command that does not name a full path acts here by default.

When you will meet it

From the first command you type, you are standing in some working directory — usually your home folder. The file you just created "disappeared"; the notes.txt you asked the agent to read "does not exist": nine times out of ten nothing is missing, you and the program are simply standing in different folders. Running pwd before launching a coding agent is the cheapest insurance there is.

An analogy

Like saying "hand me the book on the second row": that only works if everyone knows which shelf you are standing at. pwd is asking "which shelf am I actually at?" at any moment.

Minimal example

pwd                 # 印出目前的工作目錄(絕對路徑)
ls                  # 「這裡」有什麼 —— 永遠相對於工作目錄
cd notes            # 進到 notes 子資料夾
pwd                 # 再問一次,答案已經變了
cd ..               # 回到上一層

The same ls prints different things each time: "here" changed, not the command. Relative paths (notes, ../x) start from the working directory; absolute paths beginning with / or ~ do not care where you stand. PowerShell understands pwd and cd too.

What people get wrong

  • Assuming a tool opens inside your project folder. Terminals launched from a dock or an IDE usually start at your home directory; run pwd before starting an agent, or it will work against the wrong folder.
  • Using relative paths in a script and assuming they hold everywhere. They are anchored to the working directory; change the starting folder and every file "disappears".

Related terms

Next