Skip to content

refactor: merge slashcommand behavior into skill tool to reduce prompt size#1698

Merged
code-yeongyu merged 6 commits intocode-yeongyu:devfrom
Luodian:fix/merge-skill-into-slashcommand
Feb 19, 2026
Merged

refactor: merge slashcommand behavior into skill tool to reduce prompt size#1698
code-yeongyu merged 6 commits intocode-yeongyu:devfrom
Luodian:fix/merge-skill-into-slashcommand

Conversation

@Luodian
Copy link
Contributor

@Luodian Luodian commented Feb 9, 2026

Summary

This PR merges slashcommand behavior into the skill tool so we keep a single command-style entry point while reducing duplicated prompt/description surface.

Fixes #1666

Why

  • skill and slashcommand had overlapping responsibilities for command/skill discovery and execution.
  • Duplicated capability listings increased token usage.
  • Reviewer direction was to merge slashcommand behavior into the command tool path and adjust prompt/tool routing accordingly.

What Changed

  • src/plugin/tool-registry.ts

    • Registers skill as the primary tool entry.
    • Removes standalone slashcommand tool registration.
    • Passes command/skill MCP/session/git-master options into createSkillTool(...).
  • src/tools/skill/tools.ts

    • Extends skill tool to handle both skill loading and slash-command execution.
    • Adds combined listing/description generation for skills and commands.
    • Preserves MCP capability formatting and git-master config injection behavior.
  • src/tools/skill/types.ts, src/tools/skill/constants.ts

    • Updates schema/types/description text for the unified behavior.
  • src/tools/index.ts

    • Exports createSkillTool for primary routing.
    • Keeps slashcommand discovery utilities used by the unified flow.
  • src/plugin/tool-execute-before.ts

  • src/hooks/auto-slash-command/executor.ts

  • src/agents/dynamic-agent-prompt-builder.ts

    • Updates routing/categorization/error guidance to use the skill entry point.
  • src/tools/slashcommand/slashcommand-tool.ts

  • src/tools/slashcommand/types.ts

  • src/tools/slashcommand/skill-formatter.ts

    • Keeps reusable slashcommand-side utilities/formatters used by the merged flow.

Result

  • One primary tool entry (skill) for both skills and slash-style commands.
  • Lower duplicated description/prompt surface.
  • Behavior stays compatible with skill MCP capability rendering and command execution paths.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Requires human review: Large refactor merging skill tool into slashcommand tool (118 lines added). Changes MCP integration, tool routing, and core agent prompts. Cannot be 100% sure of no regressions without testing skill加载

@Luodian Luodian force-pushed the fix/merge-skill-into-slashcommand branch from a59e18e to 41b454c Compare February 9, 2026 16:01
marlon-costa-dc pushed a commit to marlon-costa-dc/oh-my-opencode that referenced this pull request Feb 10, 2026
@Luodian
Copy link
Contributor Author

Luodian commented Feb 18, 2026

@code-yeongyu Hi! should this be merged? I think it’s a valid PR to trim token usage.

@code-yeongyu
Copy link
Owner

I think merging slashcommand tool to command tool will be valid

@code-yeongyu
Copy link
Owner

And along with some prompt changes will be required

Copy link
Owner

@code-yeongyu code-yeongyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you merge slashcommand tool instead?

Copy link
Contributor Author

Luodian commented Feb 18, 2026

@code-yeongyu Correction to my previous note (that note was outdated).

This PR now follows your requested direction: merge slashcommand behavior into the skill tool (single command-style entry point), rather than removing skill in favor of slashcommand.

Current shape in this branch:

  • src/plugin/tool-registry.ts: registers skill tool; no standalone slashcommand tool registration
  • src/tools/skill/tools.ts: skill handles both skill loading and slash-command execution paths
  • src/plugin/tool-execute-before.ts: updated hook checks to skill
  • src/tools/skill-mcp/tools.ts: hint updated to load first via skill

Could you please re-review with this direction in mind?

Per reviewer feedback (code-yeongyu), keep the 'skill' tool as the main
tool and merge slashcommand functionality INTO it, rather than the reverse.

Changes:
- skill/tools.ts: Add command discovery (discoverCommandsSync) support;
  handle both SKILL.md skills and .omo/commands/ slash commands in a single
  tool; show combined listing in tool description
- skill/types.ts: Add 'commands' option to SkillLoadOptions
- skill/constants.ts: Update description to mention both skills and commands
- plugin/tool-registry.ts: Replace createSlashcommandTool with createSkillTool;
  register tool as 'skill' instead of 'slashcommand'
- tools/index.ts: Export createSkillTool instead of createSlashcommandTool
- plugin/tool-execute-before.ts: Update tool name checks from 'slashcommand'
  to 'skill'; update arg name from 'command' to 'name'
- agents/dynamic-agent-prompt-builder.ts: Categorize 'skill' tool as 'command'
- tools/skill-mcp/tools.ts: Update hint message to reference 'skill' tool
- hooks/auto-slash-command/executor.ts: Update error message

The slashcommand/ module files are kept (they provide shared utilities used
by the skill tool), but the slashcommand tool itself is no longer registered.
@Luodian Luodian force-pushed the fix/merge-skill-into-slashcommand branch from 41b454c to 462bf7b Compare February 18, 2026 16:20
@Luodian Luodian changed the title refactor: merge skill tool into slashcommand to reduce system prompt size refactor: merge slashcommand behavior into skill tool to reduce prompt size Feb 18, 2026
@Luodian Luodian closed this Feb 18, 2026
@Luodian Luodian deleted the fix/merge-skill-into-slashcommand branch February 18, 2026 17:27
@Luodian Luodian restored the fix/merge-skill-into-slashcommand branch February 18, 2026 17:28
@Luodian Luodian reopened this Feb 18, 2026
@Luodian
Copy link
Contributor Author

Luodian commented Feb 18, 2026

I noticed the current head branch name (fix/merge-skill-into-slashcommand) is a bit ambiguous.

The code itself is already minimal and valid, so if you’re okay with the branch name as-is, I’m happy to proceed with merging this PR directly.

If you’d prefer clearer naming, I can open a new PR from fix/skill-tool-unify and close this one.

@Luodian Luodian requested a review from code-yeongyu February 18, 2026 17:49
@Luodian
Copy link
Contributor Author

Luodian commented Feb 19, 2026

Token impact measurement for this PR is complete. This is based on real prompt generation with my current setup.

  • Before commit: 462bf7b2774642cf42811bde098d56e434e85d60
  • After commit: fbf3018ee4080928ba13a4c0c5d8b7eba3c5531e
  • Tokenizer: o200k_base
  • Effective skills in this prompt path during measurement: 80 = 76 custom + 4 builtin

Measured savings

Agent Before After Saved Reduction
Atlas 11,451 7,445 4,006 34.98%
Sisyphus 9,129 8,683 446 4.89%
Hephaestus 8,664 8,218 446 5.15%

Total across these 3 prompts: 4,898 tokens saved.

Why Atlas has more redundancy (detailed root cause)

Atlas had structural double-rendering of skill descriptions in a single prompt build.

  1. Atlas template contains two skill-related placeholders:
  • src/agents/atlas/default.ts:55 -> {SKILLS_SECTION}
  • src/agents/atlas/default.ts:57 -> {{CATEGORY_SKILLS_DELEGATION_GUIDE}}
  1. Atlas prompt builder fills both:
  • src/agents/atlas/agent.ts:82 -> buildSkillsSection(skills)
  • src/agents/atlas/agent.ts:83 -> buildCategorySkillsDelegationGuide(...)
  1. Before this PR, both sections expanded skill descriptions:
  • src/agents/atlas/prompt-section-builder.ts:53 (buildSkillsSection) rendered full built-in/custom skill rows.
  • src/agents/dynamic-agent-prompt-builder.ts:186 (buildCategorySkillsDelegationGuide) also rendered full built-in/custom skill rows.

So Atlas effectively had this duplication:

ATLAS PROMPT
  |- SKILLS_SECTION
  |   `- full skill description list
  `- CATEGORY+SKILLS_DELEGATION_GUIDE
      `- full skill description list again
  1. Extra amplification before this PR:
  • src/agents/dynamic-agent-prompt-builder.ts:165 (formatCustomSkillsBlock) echoed all custom skill names in a long sentence (The user installed ...).
  • Atlas had this echo in two places because both sections reused that block.

What this PR changes:

ATLAS PROMPT
  |- SKILLS_SECTION
  |   `- summary + counts only
  `- CATEGORY+SKILLS_DELEGATION_GUIDE
      `- single detailed skill-description source
  • buildSkillsSection is now a compact summary-only block.
  • The long custom-skill name echo is generalized instead of enumerating all names.

This is why Atlas saves much more than Sisyphus/Hephaestus: Atlas removed one whole duplicated description block, while the others mostly benefit from the long-name-echo reduction.

Scale note:

  • This run used 80 effective skills in this path.

@code-yeongyu
Copy link
Owner

[sisyphus-bot] Thank you for this refactoring PR. The token savings analysis (4,898 tokens, 35% reduction for Atlas) is excellent work. The direction to consolidate slashcommand into the skill tool aligns with our architecture goals. Awaiting maintainer review.

@code-yeongyu code-yeongyu merged commit 697a2f5 into code-yeongyu:dev Feb 19, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Oversized System Prompt

2 participants

Comments