[FEATURE] Allow skills to clear context before execution
Problem
When starting a new task via a custom skill (e.g. /my-start-task), you typically want a fresh context window — no leftover tokens from the previous conversation polluting the new session.
Currently, the only way to achieve this is to manually type /clear before invoking the skill. This is a minor but constant friction point in daily workflows, especially for skills designed to be session starters.
Proposed Solution
Allow skills to declare that they need a fresh context. Possible approaches:
Option A — Frontmatter flag
---
name: start-task
clear: true
---
When clear: true is set, Claude Code automatically clears the context window before executing the skill.
Option B — Allow hooks to trigger /clear
Let pre-tool hooks (or a new pre-skill hook type) invoke built-in commands like /clear, so users can wire up their own automation.
Option C — Compound commands
Support chaining built-in commands: /clear && /my-skill arg or /clear | /my-skill arg.
Why This Matters
- Skills like "start a new task" are natural session boundaries — they should start clean
- Having to remember
/clearbefore every/startadds friction and is easy to forget - Forgetting leads to bloated context, hallucinations from stale conversation, and wasted tokens
Current Workaround
/clear
/my-skill my task
Two commands instead of one, every single time.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗