Getting Started with Claude Code

Interactive Commands: How to Work with Claude Code Effectively

A practical guide to every Claude Code slash command, keyboard shortcut, and interaction pattern — what each one does and when to use it.

The Claude Code Interactive Interface

When you run claude in a project directory, you enter an interactive session. This is a persistent REPL where you issue natural language instructions, Claude Code takes actions, and you review results — all without leaving the terminal.

Understanding the command set makes the difference between an efficient workflow and a frustrating one.

Slash Commands

/help

Displays all available commands and a brief description of each.

text
/help

/clear

Clears the conversation history and resets context. Use when:

  • The conversation has become long and Claude is losing track of earlier context
  • You've completed one task and are starting a different one
  • Claude is making decisions that contradict your earlier instructions
text
/clear

After clearing, Claude still has access to your files — it just loses the conversation history. Re-state any important constraints when starting a new thread.

/compact

Compresses the current conversation into a concise summary, preserving essential context while freeing up context window space. More useful than /clear when you want to continue the same task but have accumulated a lot of back-and-forth.

text
/compact

/status

Shows the current state of Claude Code: model in use, context size, active working directory.

text
/status

/add-file and /remove-file

Explicitly add or remove files from the active context. By default, Claude Code discovers files as needed. These commands let you pre-load specific files or reduce context by removing ones that are no longer relevant.

text
/add-file src/components/UserProfile.tsx
/remove-file src/legacy/OldAuth.ts

/memory

Displays and edits Claude Code's persistent memory — information stored across sessions. You can add project notes, coding preferences, or reminders that persist between invocations.

text
/memory

/init

Generates a CLAUDE.md file for the current project by analyzing the codebase. If you don't have a CLAUDE.md yet, this is the fastest way to create one.

text
/init

Review the generated file carefully and adjust it to match your actual conventions.

Keyboard Shortcuts

ShortcutAction
Ctrl+CCancel current operation
Ctrl+DExit Claude Code
Up arrowNavigate to previous prompt
TabAutocomplete file paths in prompts
Shift+EnterMulti-line input (start a new line without submitting)

Permission Prompts

When Claude Code wants to run a shell command, modify a file, or take any irreversible action, it presents a permission prompt:

text
Claude wants to run: npm test
[y]es / [n]o / [a]lways (for this command) / [s]kip

y — Allow this one instance.

n — Deny. Claude will try an alternative approach.

a — Always allow this specific command for the rest of the session.

s — Skip this step entirely without a replacement.

The permission system is your primary safety control. Use it actively, especially for write operations and shell commands in unfamiliar projects.

Working Modes

Interactive Mode (Default)

bash
claude

Opens a persistent REPL. You converse with Claude Code over multiple turns. Best for exploratory work, debugging, and multi-step tasks.

One-Shot Mode

bash
claude -p "Add a loading spinner to the LoginButton component"

Executes one task and exits. Best for well-defined, single-step changes you want to script or automate.

Continue Mode

bash
claude --continue

Resumes the most recent conversation, preserving history. Useful when you closed a session and want to pick up exactly where you left off.

Resume Mode

bash
claude --resume

Lists recent sessions and lets you select which one to resume. Useful when you have multiple active projects with separate conversation threads.

Effective Prompting in Claude Code

Unlike chat AI where formatting is optional, Claude Code prompts benefit from specificity about scope:

Too vague:

text
Fix the auth

More effective:

text
The login form in src/pages/auth/LoginPage.tsx submits but doesn't
redirect to /dashboard after successful auth. The auth state updates
(I can see it in React DevTools) but useNavigate doesn't fire.
Look at LoginPage.tsx, AuthContext.tsx, and the router config
in App.tsx. Find the cause and fix it.

The more specific your problem description, file locations, and expected vs. actual behavior, the more targeted and accurate Claude Code's response will be.

Key Takeaways

  • /clear resets conversation history; /compact summarizes it — use /compact when you want to continue a long task
  • Permission prompts are your safety mechanism — engage with them actively rather than always approving
  • Interactive mode is for exploration and multi-step tasks; one-shot mode (-p) is for scripting and automation
  • Specific prompts with file locations and behavioral descriptions produce better results than vague requests

---

Try It Yourself: Start a Claude Code session on a project with at least 5 files. Run /init to generate a CLAUDE.md, then /status to see what model and context information Claude Code reports. Evaluate the generated CLAUDE.md — what did it get right about your project? What would you add or correct?