[FEATURE] Auto-execute slash commands on session start

Resolved 💬 2 comments Opened Oct 24, 2025 by mikemindel Closed Oct 24, 2025

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

  • SessionStart hooks 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

  1. Automatic context restoration - Sessions automatically load relevant memory/context
  2. Better user experience - No need to remember manual initialization steps
  3. Consistency - Ensures critical setup steps always happen
  4. Project-specific initialization - Different projects can have different startup commands

Example Workflow

  1. User opens Claude Code in a workspace
  2. AgentBox starts and loads .claude/settings.json
  3. Configured slash commands execute automatically
  4. MCP tools restore previous session context
  5. 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_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗