working directory
The working directory is the folder on the computer where a program or AI-agent is currently working and from which it searches for files by default.
In plain terms
Imagine working in a large office building and sitting at a desk in one room. If someone says, 'hand me the blue folder', you do not search the entire building, but look around the desk where you are sitting. The working directory is that desk: the folder the program is currently holding 'in its hand'.
This is necessary because a computer has a huge number of folders, and the program needs to know what to measure against. If you only tell it to 'open the jelentes.txt file,' it will look for it in the working directory. If the file is elsewhere, you must give the full path.
In the era of AI agents, the term has gained new significance. When you launch a coding agent in a folder, that becomes its workspace: it reads, writes, and runs commands there. By choosing the working directory, you also decide what the agent can access comfortably and what it cannot.
How it works
- Every running program keeps track of a 'current folder'; the operating system records this alongside the program.
- The program inherits this at startup: usually it receives the folder from which it was launched, for example, where you were standing in the command line. If launched from an icon, the system or the shortcut settings determine it.
- If the program searches for a file only by its name or a short, so-called relative path, the system finds it starting from the working directory.
- The working directory can be changed on the fly: in the command line, you switch to another folder with the cd command. Where you are standing is shown by the pwd command on Linux, macOS, and Windows PowerShell, and by the cd command issued alone in the traditional Windows command line.
- A coding agent takes the working directory as its starting point: it searches here for project files and instructions, and many tools only allow file modifications within this folder.
An everyday example
You ask a coding agent to reorganize your website's files, but you accidentally start it in the Documents folder instead of the website folder. The agent cannot find what it is looking for, or worse, it accesses completely different files. If you start it in the correct folder, it sees exactly what it needs to work with.
Who is affected
A common misconception
Limits and risks
- The working directory is not a security wall in itself: a program or agent can reach other locations with a full path, unless the tool's permissions or an isolated runtime environment prevent it.
- If you start a command or agent in the wrong folder, it may modify or delete the wrong files, so always check your location before starting.
- Scripts based on relative paths can easily break if someone runs them from a different folder than the one their creator expected.
- Do not run an agent in your entire user folder or at the root of the drive, as this unnecessarily exposes too many personal files to its view.
Similar, but not the same
- root directory – The root directory is the top, permanent level of the file system (the specific drive on Windows), while the working directory is the variable location where the program is currently operating.
- home directory – The home folder is the user's permanent personal directory, while the working directory can be any folder and may vary by program.
- munkafa (Git working tree) – A working tree is the instance of version-controlled project files that exists in an editable form on your machine. A working directory is simply the folder where the program currently resides, whether inside or outside the working tree.
Related concepts
file system, operating system
projektmappa
A brief history
The concept emerged in the late 1960s with hierarchical, folder-organized file systems in the Multics system and spread with the Unix operating system in the 1970s. The cd command, which changes the working directory, is still found on almost every system. The pwd command, which prints the working directory, is usable on Unix-like systems and in PowerShell.
Where things stand
A fundamental concept in every operating system for decades. As of late 2026, coding agents mean non-developers also encounter it more and more often, because it determines the agent's workspace when the agent is launched.
Also known as
working directory · munkamappa · current directory · current folder · working directory · current working directory · cwd · current directory
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.