Feature request: Context-aware instruction loading (lazy-load instructions by action type)
Hi team! One more idea from my experience using Claude Code daily. This one is more of a "wouldn't it be cool if" than a pain point, so totally understand if it's lower priority.
The pattern I noticed
I have instructions that are only relevant for specific types of work. For example, 30 lines of testing instructions that matter when running tests but are irrelevant when writing articles. Today, these either:
- Live in CLAUDE.md (always loaded, diluting attention on other instructions), or
- Live in a skill file (only loaded when I explicitly type the command)
The gap is: instructions that require judgment (not just mechanical checks, so a hook won't work) but are only relevant for a specific type of action.
What might help
Something like action-triggered instruction files. For example:
.claude/instructions/on-test.md- loaded when the model is about to run tests.claude/instructions/on-deploy.md- loaded when running deploy commands.claude/instructions/on-write-markdown.md- loaded when editing .md files
This would be similar to how the if field in hooks already filters by action pattern, but instead of running a script, it would inject instructions into the model's context.
Why I think this could be valuable
It would let users keep their CLAUDE.md lean (just core identity and routing) while having detailed, domain-specific instructions that load automatically at the right time. Less context pressure, more precise instructions.
Current workaround
I use skills for workflow-specific instructions and hooks for mechanical enforcement. It works well enough, but the automatic loading would remove the need for me to remember to invoke the right skill.
Thanks as always for the great work on Claude Code!
Environment: Claude Code CLI on macOS, 8 skill files, 10 memory files
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗