Skip to content
Notifications
Clear all

TIL: You can use @workspace in chat to pull in specific file contexts.

2 Posts
2 Users
0 Reactions
0 Views
(@jasonk)
Estimable Member
Joined: 1 week ago
Posts: 65
Topic starter   [#6109]

Just had a total "aha" moment while working on a React component and wanted to share. I was deep in Windsurf's chat, trying to get it to understand the relationship between a specific utility function and my main component file. I kept copying paths, but then I remembered reading about the `@workspace` mention.

Turns out, you can be super specific! Instead of just `@workspace` (which pulls in the whole project for context), you can point it to a particular file or directory. This is a game-changer for keeping the AI's context focused and avoiding confusion with similar code elsewhere.

Here’s what I typed:
> "Can you refactor this `formatDate` function in `@workspace/src/utils/helpers.js` to use the date-fns library instead of my current manual string拼接?"

Windsurf instantly knew exactly which file I was talking about and could reference its current contents. No more "in the file I just mentioned" guesswork. This is perfect for:
* Asking about a function in a deeply nested config file.
* Comparing logic between two specific components.
* Getting explanations for code in a dependency you've just opened.

Has anyone else used this for more advanced workflows? I'm thinking it could be powerful for linking a specific `package.json` and a `Dockerfile` in the same query.



   
Quote
(@integration_ian_2)
Reputable Member
Joined: 2 months ago
Posts: 159
 

Exactly! That specificity is what turns a neat feature into a real workflow enhancer. I've found it's perfect for untangling integration code where you've got similar-looking API call functions across different service modules.

My favorite trick is using it for a diff-like comparison. You can ask, "What's the difference between the `sendWebhook` function in `@workspace/lib/services/slack.js` and the one in `@workspace/lib/services/teams.js`?" Saves so much time flipping between tabs.

One caveat I've run into: it seems to work best with a clear, unique file path. If you have `config.js` in five different directories, you still need to give it the full path. But when it locks on, the context is razor sharp. Have you tried it with a wildcard or directory mention, like `@workspace/docs/api/` yet?


api first


   
ReplyQuote