Navigating the Claude Code REPL: Prompts and Slash Commands
Once Claude Code is running, everything happens inside a single interactive REPL session.
Search across all documentation pages
Once Claude Code is running, everything happens inside a single interactive REPL session.
That session has two kinds of input: natural-language requests, and built-in slash commands.
Knowing the difference, and knowing how to end a session properly, is the last piece of basic REPL fluency before you start relying on it for real work.
The REPL prompt is where you type a request in plain English and Claude Code turns it into a plan of action.
A leading slash marks a different kind of input: a built-in command that triggers specific REPL behavior rather than a task for the agent to plan.
Slash commands cover things like building initial project context, clearing the conversation, or compacting a long session's history.
The session persists across many requests, so you rarely need to relaunch claude in the middle of a work session.
Exiting cleanly matters because it signals you are done, rather than leaving the session hanging in a half-finished state.
Quick-reference recipe card - copy-paste ready.
# A natural-language request - plain English, no special syntax
> Add input validation to the signup form
# A slash command - built-in REPL behavior, not a task for the agent
> /init
# Clear the current conversation context
> /clear
# Exit the session cleanly
> /exitWhen to reach for this:
/init helps it build context up front./compact or /clear can help./exit closes things out properly.cd ~/projects/my-app
claude
# Build initial context about the project
> /init
# A normal natural-language request
> Explain how authentication currently works in this codebase
# A follow-up request in the same session, building on the same context
> Now add rate limiting to the login endpoint
# Free up context if the session is getting long
> /compact
# End the session when you're done
> /exitWhat this demonstrates:
/init and ordinary requests can be mixed freely in the same session./compact is available mid-session without needing to exit and relaunch./exit is the deliberate, clean way to end the session rather than closing the terminal window.> prompt is either routed to the agent as a task, or intercepted by the REPL as a slash command if it starts with /.| Command | What it does |
|---|---|
/init | Has Claude Code build up initial context about the current project |
/clear | Clears the current conversation context, starting fresh within the same session |
/compact | Compacts a long session's history to free up context while keeping the gist |
/exit | Ends the session cleanly |
# Natural language: describe the outcome, not the exact steps
> Fix the failing test in checkout.test.ts
# Slash command: always starts with a leading slash, no natural-language mixed in
> /clear/ can be misread as a command attempt. Fix: keep slash commands as the very first character of the line, with nothing else on that line./clear and /exit do the same thing - /clear resets context but keeps the session open; /exit ends the session entirely. Fix: use /clear to start fresh mid-session, and /exit only when you are actually done./exit. Fix: type /exit before closing the terminal, especially if any background command was still running./init on a new project - skipping it means the first real request has to build context from scratch, which can slow down or weaken the first plan. Fix: run /init as your first action in a brand-new project session./compact periodically in long sessions, or /clear when switching to an unrelated task.| Alternative | Use When | Don't Use When |
|---|---|---|
| Natural-language request | You want the agent to plan and act on a task | You want to control a REPL-level behavior like clearing context |
| Slash command | You want built-in REPL behavior (init, clear, compact, exit) | You want Claude Code to plan a multi-step task |
Exiting and relaunching claude | You switched to a completely different project | You are just switching tasks within the same project |
If you want Claude Code to plan and act on a task, describe it in plain English. If you want a built-in REPL behavior like clearing context or exiting, use a leading slash command instead.
/clear wipes the current conversation context and starts fresh within the same session. /compact condenses a long history down to keep it manageable without fully discarding it.
No. The session is stateful and persists across many requests. You only need to relaunch when switching to a different project directory.
The session ends abruptly rather than shutting down cleanly. It's better to type /exit first, especially if a shell command was still running.
Yes. They are commonly mixed, for example running /init first, then a series of natural-language requests, then /compact partway through a long session.
No. The slash commands covered here act on the session itself, context, history, and session lifecycle, not directly on your files. Real file edits come from natural-language requests routed through the agent.
/compact keeps a condensed version of the session's history, so the agent retains some memory of earlier context. /clear discards it entirely, which is better when you're moving to a genuinely unrelated task.
The REPL request goes through the full agent loop: reading files, planning, acting, and verifying, not just producing a text reply. That distinction is the core difference from a typical chat interface.
/init is a strong default, since it lets Claude Code build context about the project before you hand it a real task.
Stack versions: Written against the Claude model lineup current as of ~June 2026 - Claude Fable 5, Claude Opus 4.8, Claude Sonnet 5 (the default), and Claude Haiku 4.5. Model names, pricing, and product features move quickly - verify current specifics at platform.claude.com/docs before relying on them.
Reviewed by Chris St. John·Last updated Jul 18, 2026