[FEATURE] Auto-execute slash commands on session start
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Unable to execute a slash command on session start.
Proposed Solution
Feature Request: Auto-execute slash commands on session start
Summary
Add support for automatically executing slash commands when a Claude Code/AgentBox session starts, similar to how SessionStart hooks currently run shell commands.
Use Case
When using MCP servers like mcp-memory-keeper, users need to restore session context at the beginning of each session. Currently, this requires manually typing /restore-memory (or similar commands) every time a new session starts.
Current Behavior
SessionStarthooks can run shell commands that output text- Slash commands must be manually typed by the user
- There's no way to automatically execute slash commands on session initialization
Desired Behavior
Allow configuration in .claude/settings.json to auto-execute slash commands on session start:
{
"hooks": {
"SessionStart": [
{
"type": "slash-command",
"command": "/restore-memory"
}
]
}
}
Or alternatively:
{
"sessionInit": {
"commands": ["/restore-memory"]
}
}
Benefits
- Automatic context restoration - Sessions automatically load relevant memory/context
- Better user experience - No need to remember manual initialization steps
- Consistency - Ensures critical setup steps always happen
- Project-specific initialization - Different projects can have different startup commands
Example Workflow
- User opens Claude Code in a workspace
- AgentBox starts and loads
.claude/settings.json - Configured slash commands execute automatically
- MCP tools restore previous session context
- User can immediately continue working without manual setup
Alternative Considerations
If auto-executing slash commands has security concerns, consider:
- Requiring explicit opt-in via config
- Showing a prompt: "Run configured startup commands?
/restore-memory" - Adding a setting to enable/disable auto-execution
- Limiting to specific "safe" commands
Related
This would complement existing SessionStart hooks that run shell commands, providing a complete initialization system for both system-level (shell) and AI-level (slash commands) setup.
Alternative Solutions
_No response_
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗