Search⌘ K
AI Features

Core Slash Commands

Explore how OpenCode’s core slash commands enable precise control over AI coding sessions. Learn to initialize project context with /init, safely undo and redo changes, share session reasoning, compact long conversations, and reset or exit sessions. This lesson empowers you to manage stateful AI interactions effectively, making your development workflow more predictable and efficient.

Until now, we have interacted with OpenCode primarily through natural language. We ask questions, reference specific files, and execute shell commands. While this interface already feels powerful, it represents only half of the tool’s potential. The other half lies in the OpenCode command system.

Slash commands allow us to explicitly control the agent’s behavior, memory, and state. They are not merely prompts or suggestions. When we invoke a slash command, we are instructing OpenCode to perform a specific action immediately. Mastering these commands fundamentally changes how we interact with the agent, making longer and more complex development sessions far more manageable.

Why do slash commands exist?

OpenCode is stateful by design. It tracks what it has seen, what it has modified, and how the conversation has evolved throughout a session. This approach differs fundamentally from stateless chat interfaces, where every message exists in isolation.

Slash commands enable us to manage that state with precision. They allow us to initialize context, recover from errors, reset conversations, and preserve critical information, rather than relying on the model to “figure it out.” In practice, this leads to fewer misunderstandings and more predictable results.

How do we initialize the project context?

The /init command is usually the first slash command that we run in a new repository.

When we run /init, OpenCode analyzes ...