doc: my edits
This commit is contained in:
parent
d70bf1276a
commit
96278c7b75
|
|
@ -180,7 +180,7 @@ Screenshot: Verify file appears (or doesn't)
|
||||||
Step 5: Check sidebar
|
Step 5: Check sidebar
|
||||||
Screenshot: File appearing in download area
|
Screenshot: File appearing in download area
|
||||||
|
|
||||||
Step 6 (if MCP configured in Claude Desktop):
|
Step 6 (if MCP configured in Claude Desktop):
|
||||||
"Use filesystem MCP to save a file to ~/Desktop/test-mcp.txt"
|
"Use filesystem MCP to save a file to ~/Desktop/test-mcp.txt"
|
||||||
Screenshot: Compare behavior — file goes to actual local disk
|
Screenshot: Compare behavior — file goes to actual local disk
|
||||||
```
|
```
|
||||||
|
|
@ -656,210 +656,7 @@ This article is a technical tutorial/debugging-story based on personal investiga
|
||||||
|
|
||||||
# Draft
|
# Draft
|
||||||
|
|
||||||
Did you know that every Claude conversation runs in its own sandbox container with a real filesystem? Understanding how it works gives you a significant advantage. Without this knowledge, it's easy to lose work or spend time debugging "missing" files that aren't actually missing.
|
See the article text in assets/claude-virtual-filesystem-guide/text.md - this is the actual ready to publish variant.
|
||||||
|
|
||||||
Let me show you what's actually happening under the hood.
|
|
||||||
|
|
||||||
**Note:** File creation requires a paid plan (Pro, Max, Team, or Enterprise). Free users only have access to Artifacts.
|
|
||||||
|
|
||||||
## The Filesystem Structure
|
|
||||||
|
|
||||||
Here's the thing about Claude's sandbox: it's a proper Ubuntu container with a defined directory structure. Knowing these paths saves debugging time.
|
|
||||||
|
|
||||||
| Path | Contents | Persistence |
|
|
||||||
|------|----------|-------------|
|
|
||||||
| `/mnt/user-data/uploads/` | Files you upload to the chat | Persistent |
|
|
||||||
| `/mnt/user-data/outputs/` | Downloadable files visible in sidebar | Persistent |
|
|
||||||
| `/home/claude/` | Claude's working directory | ⚠️ No guarantee |
|
|
||||||
| `/mnt/skills/` | Built-in capabilities and instructions | Read-only |
|
|
||||||
|
|
||||||
You can explore this yourself:
|
|
||||||
|
|
||||||
```
|
|
||||||
view /mnt/user-data/
|
|
||||||
```
|
|
||||||
|
|
||||||
The critical distinction: files in `/mnt/user-data/` persist across sessions. Files in `/home/claude/` might disappear when the container times out.
|
|
||||||
|
|
||||||
Knowing this structure lets you navigate confidently and give Claude precise instructions — "save to outputs," "move from home directory," "show me what's in uploads."
|
|
||||||
|
|
||||||
> **Pro tip:** Files in `/home/claude/` can still be opened in the sidebar — click the filename in Claude's tool output (when it creates or edits a file). But they won't appear in the sidebar's file list until moved to outputs.
|
|
||||||
|
|
||||||
## What Happens When Claude Creates a File
|
|
||||||
|
|
||||||
When you ask Claude to create a file, it follows a two-step process. First, Claude creates the file in `/home/claude/`. Then, after finishing work on it, Claude copies it to `/mnt/user-data/outputs/` using a tool called `present_files`.
|
|
||||||
|
|
||||||
This is where things get interesting — and where most confusion happens. When Claude uses `present_files`, you end up with two copies of the same file. One in Claude's working directory, one in outputs. This duplication is the source of most confusion around file management.
|
|
||||||
|
|
||||||
## Common Problems and How to Solve Them
|
|
||||||
|
|
||||||
In simple scenarios, Claude handles files well. But in longer conversations with multiple file operations, things can go sideways. The most common issues are: Claude created a file but didn't copy it to outputs (invisible file), Claude edited the version in `/home/claude/` instead of `/mnt/user-data/outputs/` (changes don't appear), and confusion about which files you shared during the conversation.
|
|
||||||
|
|
||||||
Don't panic. Once you understand the filesystem layout, fixing these is straightforward.
|
|
||||||
|
|
||||||
## Walkthrough: The File Lifecycle in Action
|
|
||||||
|
|
||||||
Let me demonstrate with a real example. We'll build a news compilation document and watch exactly how Claude handles the file through multiple edits.
|
|
||||||
|
|
||||||
### Creating an Internal File
|
|
||||||
|
|
||||||
I started a conversation with this prompt:
|
|
||||||
|
|
||||||
```
|
|
||||||
Your task is to find and compile AI news into a single markdown document.
|
|
||||||
|
|
||||||
Workflow:
|
|
||||||
1. I give you a topic or search query
|
|
||||||
2. You search, find relevant news, select the best match, append to document
|
|
||||||
3. We repeat until I say "done"
|
|
||||||
4. You show me the complete document for final review
|
|
||||||
|
|
||||||
Rules:
|
|
||||||
- One news item per search
|
|
||||||
- All items go into the same file (append, don't overwrite)
|
|
||||||
- Include: headline, source, date, 2-3 sentence summary
|
|
||||||
|
|
||||||
Search for: the funniest AI news from the last two months
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Notice: I deliberately didn't specify where to create the file. Moreover, I hinted to Claude that work on the file would continue through my subsequent requests — this pushes it toward working with an internal file. In practice, this is a common scenario: Claude works with files internally without showing them to the user until completion. As a result, Claude created `ai-news-compilation.md` in `/home/claude/`. The file is NOT visible in the sidebar.
|
|
||||||
|
|
||||||
### Appending Content
|
|
||||||
|
|
||||||
I continued with another request:
|
|
||||||
|
|
||||||
```
|
|
||||||
Now find the most important news about AI image generation
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Claude uses `str_replace` to append content. The file still isn't in the sidebar — it's an internal working file.
|
|
||||||
|
|
||||||
### Viewing Internal Files
|
|
||||||
|
|
||||||
What if I want to see the contents? Click the filename in Claude's tool output.
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
The file opens in the sidebar preview panel:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
But notice: it's a preview, not an entry in the file list. This file is still in `/home/claude/` and could disappear.
|
|
||||||
|
|
||||||
### Moving to Outputs
|
|
||||||
|
|
||||||
To make the file persistent and downloadable:
|
|
||||||
|
|
||||||
```
|
|
||||||
move this file to /mnt/user-data/outputs/
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
Claude runs `mv /home/claude/ai-news-compilation.md /mnt/user-data/outputs/`. Now it appears in the sidebar's file list. Since we moved (not copied), there's only ONE file to work with. Clean.
|
|
||||||
|
|
||||||
### The "Wrong File" Problem
|
|
||||||
|
|
||||||
Let's test another scenario. We'll start a new conversation with the same initial request for news compilation. This time, let's see what happens when Claude uses `present_files`.
|
|
||||||
|
|
||||||
I added a few news items, and here's where things break down:
|
|
||||||
|
|
||||||
```
|
|
||||||
Find the most performant AI coding agent released in the last two months
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
What happened? Claude edited a file in `/home/claude/` — not the one in `/mnt/user-data/outputs/`. If `present_files` was used earlier, both locations have the file. Claude picked the working copy.
|
|
||||||
|
|
||||||
The sidebar shows the old version. The new content exists only in `/home/claude/`.
|
|
||||||
|
|
||||||
This situation is common when working with complex multi-step scenarios. Claude doesn't always track which copy you care about — especially in longer conversations with many file operations.
|
|
||||||
|
|
||||||
### The Fix
|
|
||||||
|
|
||||||
Simple solution:
|
|
||||||
|
|
||||||
```
|
|
||||||
move this file from /home/claude to /mnt/user-data/outputs/ (override the existing file)
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
The updated file overwrites the old one. Sidebar now shows all content including the latest addition.
|
|
||||||
|
|
||||||
### Summary
|
|
||||||
|
|
||||||
What we learned: Claude creates working files in `/home/claude/` by default. Files only appear in sidebar when in `/mnt/user-data/outputs/`. The `present_files` tool creates a copy, resulting in two files. Claude may edit the "wrong" file when duplicates exist. Solution: explicitly move or copy to outputs when needed.
|
|
||||||
|
|
||||||
## Quick Reference: Tools and Commands
|
|
||||||
|
|
||||||
Claude uses these tools internally: `view` for reading files and directories, `str_replace` for editing content, `create_file` for new files, `bash_tool` for shell commands, and `present_files` for making files downloadable.
|
|
||||||
|
|
||||||
You interact with natural language. Try these prompts:
|
|
||||||
|
|
||||||
- "Show me what's in /mnt/user-data/" — triggers view
|
|
||||||
- "Create a file test.txt with 'hello world'" — triggers create_file
|
|
||||||
- "Run `ls -la /home/claude/`" — triggers bash
|
|
||||||
- "Copy test.txt to /mnt/user-data/outputs/" — triggers bash with cp
|
|
||||||
- "Show me the file for download" — triggers present_files
|
|
||||||
|
|
||||||
Tool names are implementation details. Claude picks the right one automatically.
|
|
||||||
|
|
||||||
## Why This Matters: Filesystem MCP
|
|
||||||
|
|
||||||
Understanding the internal filesystem is one thing. But when you add Filesystem MCP to the mix, there are now two filesystems Claude can work with — and this is where confusion multiplies. Claude might read from one and write to another without you noticing. I've been burned by this more than once: expecting a file on my local disk, finding it only in the sandbox, or vice versa. In these scenarios, explicit instructions matter.
|
|
||||||
|
|
||||||
Filesystem MCP gives Claude access to your local disk. True persistence, files land directly in your project directory, ready for version control. Downside: requires setup and only works in Claude Desktop (not the web interface).
|
|
||||||
|
|
||||||
But here's the catch. Adding MCP complicates the system: it's no longer enough to say "create a file" or "copy file to folder." You need to be more precise with your commands and clarify which filesystem you mean — the internal sandbox or your local disk via MCP.
|
|
||||||
|
|
||||||
Use sandbox for quick explorations. Use MCP for serious projects where files need to persist.
|
|
||||||
|
|
||||||
The most productive approach — edit files with Claude in its sandbox, then save them to disk:
|
|
||||||
|
|
||||||
```
|
|
||||||
read (Filesystem MCP) → edit (sandbox) → write (Filesystem MCP)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Bonus: The Two-Tab Experiment
|
|
||||||
|
|
||||||
Let's have some fun to wrap up, and also confirm that we have access to the same container when opening the same chat in different tabs or in Claude Desktop.
|
|
||||||
|
|
||||||
Try this:
|
|
||||||
|
|
||||||
**Tab 1:**
|
|
||||||
```
|
|
||||||
Create a file `/home/claude/test.txt` with a content "hello world"
|
|
||||||
```
|
|
||||||
|
|
||||||
**Tab 2** (same chat):
|
|
||||||
```
|
|
||||||
Change the file content to "hello claude"
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
**Tab 1:**
|
|
||||||
```
|
|
||||||
output the content of that file
|
|
||||||
```
|
|
||||||
|
|
||||||
The content is "hello claude". Claude in Tab 1 is confused — it doesn't see the modification command in its conversation history, but the file has changed.
|
|
||||||
|
|
||||||
This confirms: the sandbox container is shared across all sessions of the same chat. The filesystem is consistent, even if conversation history isn't.
|
|
||||||
|
|
||||||
## What's Next
|
|
||||||
|
|
||||||
That's the filesystem. No magic, just directories and persistence rules.
|
|
||||||
|
|
||||||
Now you know how it works — which means you can direct Claude precisely where to save, what to edit, and when to move files to outputs. Next time something seems off, you'll know exactly where to look.
|
|
||||||
|
|
||||||
Go build something great with Claude. Your files will be exactly where you need them.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,9 @@ Let me show you what's actually happening under the hood.
|
||||||
|
|
||||||
Here's the thing about Claude's sandbox: it's a proper Ubuntu container with a defined directory structure. Knowing these paths saves debugging time.
|
Here's the thing about Claude's sandbox: it's a proper Ubuntu container with a defined directory structure. Knowing these paths saves debugging time.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
You can explore this yourself. [Start a new chat with Claude type the prompt]:
|
You can explore this yourself. Start a new Claude chat and try this prompt:
|
||||||
|
|
||||||
```
|
```
|
||||||
view /mnt/user-data/
|
view /mnt/user-data/
|
||||||
|
|
@ -40,7 +40,7 @@ Let me demonstrate with a real example. We'll build a news compilation document
|
||||||
|
|
||||||
### Creating an Internal File
|
### Creating an Internal File
|
||||||
|
|
||||||
[Let's go through a process of some kind of file editing work in a new Claude chat. Follow my requests. You can copy-paste them into your chat.] I started a conversation with this prompt:
|
Follow along in a fresh Claude chat — you can copy-paste these prompts directly. I started a conversation with this prompt:
|
||||||
|
|
||||||
```
|
```
|
||||||
Your task is to find and compile AI news into a single markdown document.
|
Your task is to find and compile AI news into a single markdown document.
|
||||||
|
|
@ -59,9 +59,9 @@ Rules:
|
||||||
Search for: the funniest AI news from the last two months
|
Search for: the funniest AI news from the last two months
|
||||||
```
|
```
|
||||||
|
|
||||||
[And here is the screenshot with a result:]
|
Here's what happened:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Notice: I deliberately didn't specify where to create the file. Moreover, I hinted to Claude that work on the file would continue through my subsequent requests — this pushes it toward working with an internal file. In practice, this is a common scenario: Claude works with files internally without showing them to the user until completion. As a result, Claude created `ai-news-compilation.md` in `/home/claude/`. The file is NOT visible in the sidebar.
|
Notice: I deliberately didn't specify where to create the file. Moreover, I hinted to Claude that work on the file would continue through my subsequent requests — this pushes it toward working with an internal file. In practice, this is a common scenario: Claude works with files internally without showing them to the user until completion. As a result, Claude created `ai-news-compilation.md` in `/home/claude/`. The file is NOT visible in the sidebar.
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ I continued with another request:
|
||||||
Now find the most important news about AI image generation for the last two months
|
Now find the most important news about AI image generation for the last two months
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Claude uses `str_replace` to append content. The file still isn't in the sidebar — it's an internal working file.
|
Claude uses `str_replace` to append content. The file still isn't in the sidebar — it's an internal working file.
|
||||||
|
|
||||||
|
|
@ -81,29 +81,29 @@ Claude uses `str_replace` to append content. The file still isn't in the sidebar
|
||||||
|
|
||||||
What if I want to see the contents? Click the filename in Claude's tool output.
|
What if I want to see the contents? Click the filename in Claude's tool output.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The file opens in the sidebar preview panel:
|
The file opens in the sidebar preview panel:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
But notice: it's a preview, not an entry in the file list. This file is still in `/home/claude/` and could disappear.
|
But notice: it's a preview, not an entry in the file list. This file is still in `/home/claude/` and could disappear.
|
||||||
|
|
||||||
### Moving to Outputs
|
### Moving to Outputs
|
||||||
|
|
||||||
To make the file persistent and downloadable. [Ask Claude to move our working file into another folder:]
|
To make the file persistent and downloadable, ask Claude to move it:
|
||||||
|
|
||||||
```
|
```
|
||||||
move this file to /mnt/user-data/outputs/
|
move this file to /mnt/user-data/outputs/
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Claude runs `mv /home/claude/ai-news-compilation.md /mnt/user-data/outputs/`. Now it appears in the sidebar's file list. Since we moved (not copied), there's only ONE file to work with. Clean.
|
Claude runs `mv /home/claude/ai-news-compilation.md /mnt/user-data/outputs/`. Now it appears in the sidebar's file list. Since we moved (not copied), there's only ONE file to work with. Clean.
|
||||||
|
|
||||||
### The "Wrong File" Problem
|
### The "Wrong File" Problem
|
||||||
|
|
||||||
Let's test another scenario. We'll start a new conversation with the same initial request for news compilation. [ask to create a few news first]
|
Let's test another scenario. Start a new conversation with the same initial news compilation request and add a few news items first.
|
||||||
|
|
||||||
This time, let's see what happens when Claude uses `present_files`:
|
This time, let's see what happens when Claude uses `present_files`:
|
||||||
|
|
||||||
|
|
@ -111,16 +111,16 @@ This time, let's see what happens when Claude uses `present_files`:
|
||||||
present this file to me
|
present this file to me
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
[Looks good, but now let's continue adding news. Ask Claude to add a new one]:
|
The file appears in the sidebar. Now continue adding news:
|
||||||
|
|
||||||
```
|
```
|
||||||
Find the most performant AI coding agent released in the last two months
|
Find the most performant AI coding agent released in the last two months
|
||||||
```
|
```
|
||||||
Check the file in sidebar.
|
Check the file in sidebar.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
What happened? Claude edited a file in `/home/claude/` — not the one in `/mnt/user-data/outputs/`. If `present_files` was used earlier, both locations have the file. Claude picked the working copy.
|
What happened? Claude edited a file in `/home/claude/` — not the one in `/mnt/user-data/outputs/`. If `present_files` was used earlier, both locations have the file. Claude picked the working copy.
|
||||||
|
|
||||||
|
|
@ -136,7 +136,7 @@ Simple solution:
|
||||||
move this file from /home/claude to /mnt/user-data/outputs/ (override the existing file)
|
move this file from /home/claude to /mnt/user-data/outputs/ (override the existing file)
|
||||||
```
|
```
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The updated file overwrites the old one. Sidebar now shows all content including the latest addition.
|
The updated file overwrites the old one. Sidebar now shows all content including the latest addition.
|
||||||
|
|
||||||
|
|
@ -170,23 +170,21 @@ Use sandbox for quick explorations. Use MCP for serious projects where files nee
|
||||||
|
|
||||||
The most productive approach — edit files with Claude in its sandbox, then save them to disk:
|
The most productive approach — edit files with Claude in its sandbox, then save them to disk:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
## Bonus: The Two-Tab Experiment
|
## Bonus: The Two-Tab Experiment
|
||||||
|
|
||||||
Let's have some fun to wrap up, and also confirm that we have access to the same container when opening the same chat in different tabs or in Claude Desktop.
|
Let's have some fun to wrap up, and also confirm that we have access to the same container when opening the same chat in different tabs or in Claude Desktop.
|
||||||
|
|
||||||
[Try this. Start a new chat with Claude in your browser.]
|
Try this in a new Claude chat:
|
||||||
|
|
||||||
**Tab 1:**
|
**Tab 1:**
|
||||||
|
|
||||||
[Type a simple prompt:]
|
|
||||||
|
|
||||||
```
|
```
|
||||||
Create a file `/home/claude/test.txt` with a content "hello world"
|
Create a file `/home/claude/test.txt` with a content "hello world"
|
||||||
```
|
```
|
||||||
|
|
||||||
[Then open the same chat in another browser tab. The first one should remain open]
|
Now open this same chat in a second browser tab (keep the first one open):
|
||||||
|
|
||||||
**Tab 2** (same chat):
|
**Tab 2** (same chat):
|
||||||
|
|
||||||
|
|
@ -194,19 +192,17 @@ Create a file `/home/claude/test.txt` with a content "hello world"
|
||||||
Change the file content to "hello claude"
|
Change the file content to "hello claude"
|
||||||
```
|
```
|
||||||
|
|
||||||
[Switch back to the first tab. DON'T refresh the page]
|
Switch back to Tab 1 (don't refresh):
|
||||||
|
|
||||||
**Tab 1:**
|
**Tab 1:**
|
||||||
|
|
||||||
type:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
output the content of that file
|
output the content of that file
|
||||||
```
|
```
|
||||||
|
|
||||||
[Claude will read the file content again:]
|
Claude reads the file:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The content is "hello claude". Claude in Tab 1 is confused — it doesn't see the modification command in its conversation history, but the file has changed.
|
The content is "hello claude". Claude in Tab 1 is confused — it doesn't see the modification command in its conversation history, but the file has changed.
|
||||||
|
|
||||||
|
|
@ -218,4 +214,4 @@ That's the filesystem. No magic, just directories and persistence rules.
|
||||||
|
|
||||||
Now you know how it works — which means you can direct Claude precisely where to save, what to edit, and when to move files to outputs. Next time something seems off, you'll know exactly where to look.
|
Now you know how it works — which means you can direct Claude precisely where to save, what to edit, and when to move files to outputs. Next time something seems off, you'll know exactly where to look.
|
||||||
|
|
||||||
Go build something great with Claude [and fill confident about your work]
|
Go build something great with Claude — and feel confident about your work.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue