Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Claude Code Operation Guide

Claude Code Operation Guide

Claude Code's input box is not a pure chat box, but rather a:

A fused terminal of AI + editor + command dispatcher

There are three main types of prefix triggers:

sign before positive numbers Type Essential function
/ Command Execute built-in operations
@ Context Reference files/code/directories
! Bash mode Directly execute terminal commands; stdout/stderr are automatically injected into the context
# Memory (memory injection) Persistently write content to the CLAUDE.md project memory, taking effect across sessions long-term, e.g.: #config.yaml
& Async (asynchronous tasks) Execute tasks asynchronously in the background/cloud without blocking the current session; you can close the terminal and check progress at claude.ai/code
\+Enter Multiline (multi-line input) Line breaks don't send, so you can write multi-line content and complete long requirement descriptions all at once
No prefix Natural language Normal task instruction

/ —— Action commands (most important)

/ is the core symbol in Claude Code that triggers built-in commands / tools, similar to the instruction prefix of a terminal command line, used to tell Claude to perform a specific operation rather than simply generate text.

**Core purpose:** invoke built-in functions (such as code generation, file operations, environment execution, plugin invocation, etc.).

The command keyword immediately follows /, with parameters after a space (such as file names, commands to execute, fix targets, etc.), which is how Claude Code distinguishesnatural language conversationandfrom code operation instructionsthe key.

Input / A command list pops up:

Common high-frequency commands:

Command Purpose
/help View all capabilities
/clear Clear conversation
/plan Enter plan mode
/model Switching models
/context View context usage
/export Export conversation
/status Environment status
/tasks Manage background tasks
/theme Theme switching
/memory Edit CLAUDE.md

For example:

//plan 实现一个用户登录模块


@ —— Context injection

Following @ with a file name triggers active association:

Reference a single file:

@main.py 帮我检查 bug

Reference multiple files:



@main.py @main2.py 这两个是否有重复逻辑?

Reference an entire directory

@ + directory path

:

@src/ 分析项目结构并给出优化建议

Reference error logs:



@npm-debug.log 找出失败原因

Claude actually loads the file content into the reasoning context.


! -- Bash command

By adding before the input

!

you can run bash commands directly without going through Claude, in the format:

! + Bash 命令

Typing ! prompts entry into Bash command mode:

For example, to view the current directory:



! ls -la


Vim editor mode

Use /vim command enables vim-style editing, or through /config permanent configuration.

Mode switching

Command Operation From mode
Esc Enter NORMAL mode INSERT
i Insert before the cursor NORMAL
I Insert at the beginning of the line NORMAL
a Insert after the cursor NORMAL
A Insert at the end of the line NORMAL
o Open a line below NORMAL
O Open a line above NORMAL

Navigation (NORMAL mode)

Command Operation
h/j/k/l Move left/down/up/right
w Next word
e End of word
b Previous word
0 Line start
$ Line end
^ First non-whitespace character
gg Start of input
G End of input
f{char} Jump to the next occurrence of a character
F{char} Jump to the previous occurrence of a character
t{char} Jump to before the next occurrence of a character
T{char} Jump to after the previous occurrence of a character
; Repeat the last f/F/t/T motion
, Repeat the last f/F/t/T motion in reverse

Editing (NORMAL mode)

Command Operation
x Delete character
dd Drop rows
D Delete to end of line
dw/de/db Delete word/to end/backward
cc Change line
C Change to end of line
cw/ce/cb Change word/to end/backward
yy/Y Yank (copy) line
yw/ye/yb Yank word/to end/backward
p Paste after the cursor
P Paste before the cursor
>> Indent line
<< Unindent line
J Join lines
. Repeat the last change

Text objects (NORMAL mode)

Text objects work with d、c and y operators such as these:

Command Operation
iw/aw inner/around word
iW/aW inner/around WORD (space-delimited)
i"/a" inner/around double quotes
i'/a' inner/around single quotes
i(/a( inner/around parentheses
i[/a[ inner/around square brackets
i{/a{ inner/around curly braces

Command history

Claude Code maintains command history for the current session:

Use Ctrl+R for reverse search

Press Ctrl+R Interactively search your command history:

- Press `Tab` or `Esc` to accept the current match and continue editing - Press `Enter` to accept and execute immediately - Press `Ctrl+C` to cancel and restore the original input - Press `Backspace` on an empty search to cancel

The search displays matching commands with the search term highlighted, making it easy to find and reuse previous inputs.


Background bash commands

Claude Code supports running bash commands in the background, allowing you to continue working while long-running processes execute.

How background execution works

When Claude Code runs a command in the background, it runs the command asynchronously and immediately returns a background task ID. Claude Code can respond to new prompts while the command continues executing in the background.

To run a command in the background, you can:

Main features:

To disable all background task features, set CLAUDE_CODE_DISABLE_BACKGROUND_TASKS environment variable to 1。

Common background commands:

Use ! Bash mode with prefix

By adding before the input ! Run bash commands directly without going through Claude:



! npm test

! git status

! ls -la

Bash mode:

This is useful for quick shell operations while maintaining conversation context.


Key descriptions

General controls

Keyboard shortcut Description Context
Ctrl+C Cancel current input or generation Standard interrupt
Ctrl+D Exit Claude Code session EOF signal
Ctrl+G Open in the default text editor Edit your prompt or custom response in the default text editor
Ctrl+L Clear the terminal screen Preserve conversation history
Ctrl+O Toggle verbose output Show detailed tool usage and execution
Ctrl+R Reverse-search command history Interactively search previous commands
Ctrl+V or Cmd+V(iTerm2) or Alt+V(Windows) Paste an image from the clipboard Paste an image or the path to an image file
Ctrl+B Run a task in the background Run bash commands and agents in the background. Tmux users press twice
Left/Right arrows Cycle between dialog tabs Navigate between tabs in the permission dialog and menus
Up/Down arrows Navigate command history Recall previous inputs
Esc + Esc Revert code/conversation Restore code and/or conversation to a previous state
Shift+Tab or Alt+M(some configurations) Toggle permission mode Switch between auto-accept mode, Plan Mode, and normal mode
Option+P(macOS) or Alt+P(Windows/Linux) Switching models Switch models without clearing the prompt
Option+T(macOS) or Alt+T(Windows/Linux) Toggle extended thinking Enable or disable extended thinking mode. First run /terminal-setup to enable this shortcut key

Text Editing

Keyboard shortcut Description Context
Ctrl+K Delete to end of line Store deleted text for pasting
Ctrl+U Delete a whole line Store deleted text for pasting
Ctrl+Y Paste deleted text Paste with Ctrl+K or Ctrl+U deleted text
Alt+Y(in Ctrl+Y after) Cycle through paste history After pasting, cycle through previously deleted text. On macOS, you need toset Option to Meta
Alt+B Move the cursor back one word Word navigation. On macOS, you need toset Option to Meta
Alt+F Move the cursor forward one word Word navigation. On macOS, you need toset Option to Meta

Theme and display

Keyboard shortcut Description Context
Ctrl+T Toggle syntax highlighting for code blocks Only when /theme Works within picker menus. Controls whether code in Claude's responses uses syntax coloring

Syntax highlighting is only available in native builds of Claude Code.

Multi-line input

Method Keyboard shortcut Context
Quick escape \ + Enter Works in all terminals
macOS default Option+Enter Default settings on macOS
Shift+Enter Shift+Enter Works out of the box in iTerm2, WezTerm, Ghostty, Kitty
Control sequences Ctrl+J Newline for multiple lines
Paste mode Direct paste For code blocks, logs

Shift+Enter works without configuration in iTerm2, WezTerm, Ghostty, and Kitty. For other terminals (VS Code, Alacritty, Zed, Warp), run /terminal-setup to install the binding.