claude-code - 💡(How to fix) Fix [FEATURE] Allow skills to clear context before execution [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45091Fetched 2026-04-09 08:13:30
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Author
Timeline (top)
labeled ×2commented ×1cross-referenced ×1

Root Cause

  • Skills like "start a new task" are natural session boundaries — they should start clean
  • Having to remember /clear before every /start adds friction and is easy to forget
  • Forgetting leads to bloated context, hallucinations from stale conversation, and wasted tokens

Fix Action

Fix / Workaround

Current Workaround

Code Example

---
name: start-task
clear: true
---

---

/clear
/my-skill my task
RAW_BUFFERClick to expand / collapse

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 /clear before every /start adds 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.

extent analysis

TL;DR

Implementing a feature to automatically clear the context window before executing a skill, such as through a frontmatter flag or allowing hooks to trigger the /clear command, would likely resolve the issue.

Guidance

  • Consider implementing Option A, the frontmatter flag, as it provides a straightforward way for skills to declare the need for a fresh context.
  • Evaluate the feasibility of Option B, allowing hooks to trigger /clear, to provide more flexibility in automating the clearing of the context window.
  • Assess the potential benefits and challenges of implementing Option C, compound commands, to support chaining built-in commands like /clear and /my-skill.
  • Verify that the chosen solution effectively clears the context window before executing the skill and does not introduce any unintended side effects.

Example

---
name: start-task
clear: true
---

This example illustrates how a skill could declare the need for a fresh context using the proposed frontmatter flag.

Notes

The best approach may depend on the specific requirements and constraints of the system, such as performance considerations and potential security implications.

Recommendation

Apply a workaround, such as using the current workaround of typing /clear before invoking the skill, until a more permanent solution can be implemented, as it provides a temporary fix to the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING