Magic Tools
AI TutorialsBy CooconMarch 29, 20261706 views2 min read

Claude Code Memory and Commands: CLAUDE.md, Slash Commands, and Workflow Shortcuts

Claude Code gets much more useful when you stop repeating the same instructions in every session. Anthropic's memory system and slash commands are the two features that make that possible. One preserves context across sessions. The other gives you fast controls for common actions while you are working.

The result is a more stable workflow: project rules stay in CLAUDE.md, personal preferences stay in your user memory, and session commands let you adjust Claude without rewriting the prompt from scratch.

How Claude Code memory works

Anthropic documents memory as a hierarchy with several layers:

  1. Enterprise policy memory for organization-wide instructions
  2. Project memory in ./CLAUDE.md
  3. User memory in ~/.claude/CLAUDE.md

That structure matters because it separates team-wide conventions from your own preferences. In practice, it lets Claude read the right instructions automatically when you open a project.

Claude Code also looks up memory files recursively from the current working directory, which is useful in larger repositories. You can see loaded memories with the /memory command.

What belongs in project memory

Use CLAUDE.md for instructions that should travel with the codebase:

  • Build and test commands
  • Naming conventions
  • Architecture notes
  • Team-specific coding rules
  • Common workflow reminders

The goal is to store the instructions you would otherwise keep repeating at the start of every session. That saves time and reduces inconsistency.

How to add or edit memory quickly

Anthropic provides two easy paths:

  • Start a message with # to add a memory quickly
  • Use /memory to open the relevant memory file in your editor

Example:

# Always prefer small, reviewable changes

That is enough to capture a simple preference without interrupting your flow.

Slash commands that matter most

The built-in slash commands Anthropic highlights are especially practical for day-to-day work:

  • /init to initialize a project with a CLAUDE.md guide
  • /clear to clear conversation history
  • /compact to compress the conversation when it gets too long
  • /config to view or modify configuration
  • /mcp to manage MCP connections
  • /model to switch models
  • /permissions to review or update permissions
  • /help to see what is available

These commands let you adjust the session without breaking your flow or retyping large instructions.

Custom commands for repetitive work

Anthropic also supports custom slash commands stored as Markdown files. That is useful when your team repeats the same tasks often.

Project commands live in .claude/commands/, and personal commands live in ~/.claude/commands/. You can use them for things like:

  • Code review checklists
  • Security review prompts
  • Refactor instructions
  • Documentation update workflows

If you routinely ask Claude to do the same kind of task, a command is often better than a long prompt because it is easier to reuse and easier to keep consistent.

A simple memory strategy

Use a three-layer rule:

  1. Put team rules in project memory
  2. Put personal defaults in user memory
  3. Put one-off instructions in the current session

That keeps Claude Code predictable. It also reduces the temptation to stuff everything into a single prompt.

Official References

Sources reviewed on March 29, 2026. Feature availability, plan limits, and interface details can change, so confirm current behavior in the linked official Anthropic resources.

Related Articles

Reproducing an Injection Chain That Cracks Claude Code Auto Mode: the Model Refuses the Malicious Binary, Then Writes Code That Pwns Itself

In late August embracethered published an attack chain where a plain 'summarize this page' request drags auto-mode Claude Code to a 60–80% code-execution rate — while Anthropic's commissioned third-party test reported 0.00%. I took the chain apart and tested it stage by stage in an isolated environment: the endpoint that nudges the model from WebFetch to curl, and the crux — the model's own 'safe' decision to refuse the unknown binary and write its own Python decoder instead lands straight on a same-name struct.py planted in the extracted directory. The deterministic parts (branching + module-shadow poison + mitigation controls) reproduce fully on my machine with real evidence; the live end couldn't complete a full RCE here because the classifier rate-limited and failed closed — flagged honestly. Ends with mitigations that actually help.

claude-codeauto-mode+5
hands-onAug 31, 20269 min
106

Cracking Open Claude Code's Auto-Mode Classifier: A 116K-Char System Prompt, Dissected Line by Line

My earlier retest confirmed auto mode calls the session model as a classifier before each risky Bash — but what it receives stayed a black box. This time I captured the full request: a 116,879-char system prompt opening 'You are a security monitor for autonomous AI coding agents.' I quote it verbatim to dissect the threat model, two-tier rules (1 HARD BLOCK / 68 SOFT BLOCK / 17 ALLOW), and two-stage evaluation — stage 1 grades harm only, stage 2 layers intent on top. Every number read out this session.

claude-codepermissions+5
hands-onAug 30, 202612 min
155
Turn a Home Mac mini Into an Always-On Claude Code Workstation: claudecodeui + SSH Reverse Tunnel, Take Over Sessions From Any Browser

Turn a Home Mac mini Into an Always-On Claude Code Workstation: claudecodeui + SSH Reverse Tunnel, Take Over Sessions From Any Browser

A Mac mini at home runs Claude Code around the clock — but how do you take over a session from a browser when you're away? This is a real setup that has been live for a week and in daily use: claudecodeui as the web UI (chosen over the official web version, ttyd, and code-server), an SSH reverse tunnel pushing it to a VPS, and nginx adding TLS plus login rate limiting to turn it into an ordinary URL. Includes full configs, real operating numbers (five days of tunnel uptime with zero drops, 170MB RSS), a <synthetic> placeholder bug hit and fixed within the first week, and an honest for-and-against on why not Tailscale.

claude-codeclaude-code-lab+7
claudeAug 29, 202612 min
153

Claude's Aug 24 Outage: Elevated Errors Hit Opus 5, Fable 5, Mythos 5 for 2h46m

Full recap of the Aug 24 Claude API outage: elevated errors from 04:50–07:36 UTC across Claude Mythos 5, Fable 5, Opus 5 and Opus 4.8, hitting claude.ai, the API, Claude Code and Cowork. Includes the verbatim status-page timeline and tips for developers.

claudeapi+3
ai-tutorialsAug 25, 20263 min
262

Published by Magic Tools