How to Build a /context Command in Claude Code

Published by

on

Nine neon folders labeled Projects, Important, Work, Finances, Personal, Photos, Design, Videos, Archive

If you use Claude, you’ve probably run out of tokens. You have to explain what you’ve done to Claude again, or try to find the chat window you used. You load all your notes when you’re trying to think about a personal goal or flood the context with work projects when you just need to check in on one specific thing.

There’s an easy way to save tokens: parameterized context loading. One command, multiple modes.

What Is the /context Command?

Claude Code lets you create custom slash commands by dropping a Markdown file into ~/.claude/commands/. When you type /context in the Claude Code prompt, it runs the instructions in context.md — reading files, searching your vault, and synthesizing a summary for Claude to work from.

By default, most people write a single context loader that reads everything. That’s fine when you’re starting out, but it doesn’t scale.

The Token Problem

Every file Claude reads costs tokens. Tokens are the unit of “how much Claude can hold in its head at once” — and they directly affect cost if you’re on a paid API plan, and response quality regardless of plan.

When your /context command reads your entire vault — every project, every area, every calendar entry — you might be burning 10,000–30,000+ tokens just on context loading before you’ve typed a single question. That’s waste.

More importantly, a bloated context window creates noise. Claude has to reason across everything you loaded, even the irrelevant parts. Focused context = sharper answers.

The fix: only load what you actually need for the task at hand.

The Parameterized Approach

Claude Code passes any text after the command name into the skill as $ARGUMENTS. So instead of one monolithic contex:

/context consultant   → loads only consulting clienterables, projects
/context personal     → loads personal goals, habits, calendar
/context work         → loads work responsibilities and deadlines
/context project   → loads only the  project folder

Each mode reads a focused slice of your vault instead of the whole thing. For a typical vault, this can cut context token usage by 60–80% per session.

How to Set It Up

Your vault structure drives the routing. Here’s an example layout (this works great with Obsidian’s PARA or similar folder structure):

/ObsidianVaults//
  Areas/
    Consultant Business/
    Personal/
    





Then update your ~/.claude/commands/context.md to parse $ARGUMENTS and branch accordingly:

Load context from the YUMMY Obsidian vault based on the parameter: $ARGUMENTS
Parse $ARGUMENTS and follow the matching section below.
If no argument is given, run Full Context.
---
### `consultant`
1. Read Areas/Consultant Business/ — all .md files
2. Glob Projects/ for consulting-related files
3. Grep for "consultant" or "client" across vault
4. Summarize: Active Clients, Deliverables, Next Actions
---
### `personal`
1. Read Personal/ folder
2. Read Areas/Personal/ — all .md files
3. Grep for dates in the last 7 days
4. Summarize: Goals, Health, Relationships, Upcoming
---
### `work`
1. Read Areas/Work/ — all .md files
2. Glob Projects/ for work-related files
3. Summarize: Projects, Responsibilities, Deadlines, Next Actions
---
### `project <name>`
1. Extract project name from argument
2. Glob Projects/<name>/ — all .md files
3. Grep for project name across vault for cross-references
4. Summarize: Goal, Status, Blockers, Next Actions
---
### Full Context (no argument)
1. Read Projects/Projects.md, Areas/Areas.md, Inbox/Inbox.md
2. Glob all .md in Projects/ and Areas/
3. Read Personal/
4. Grep for last 7 days of dates
5. Summarize everything

The Parameter Is the Most Powerful

The project parameter is open-ended by design. You don’t hardcode a list of project names — you just create folders inside your Projects/ directory and call them by name:

/context project Podcast
/context project HomeReno
/context project ClientABC

Claude reads only that folder plus any cross-references. If the folder doesn’t exist, it lists what’s available so you can pick the right name. No configuration needed — just create the folder and it works.

Token Savings in Practice

Here’s a rough comparison for a medium-sized vault (50–80 notes):

ModeFiles ReadApprox. Tokens
/context (full)50–80 files15,000–40,000
/context work10–20 files3,000–8,000
/context project X3–10 files1,000–4,000

Over dozens of sessions, that adds up to a meaningfully faster, cheaper, and more focused workflow.

Getting Started

  1. Open ~/.claude/commands/context.md (create it if it doesn’t exist)
  2. Add parameter-based routing using the template above, adjusted to your vault’s folder structure
  3. Create subfolders in your Projects/ directory for anything you want to load by name
  4. Start every Claude Code session with the narrowest context that covers what you’re working on

Full context is still there when you need it — just run /context with no argument. But most of the time, you won’t need it.


This is part of an ongoing series on using Claude Code as a personal operating system for knowledge workers and consultants.

Leave a comment