Claude Code Automation: Auto Memory and the /loop Command
Claude Code introduces Auto Memory for persistent context and the /loop command for recurring tasks. Build self-improving workflows with automatic knowledge retention and scheduled automation.
Claude Code has steadily evolved from a reactive coding assistant into something closer to an autonomous development partner. Two recent features mark a significant step in that direction: Auto Memory (introduced in v2.1.59) and the /loop command (introduced in v2.1.71). Together, they let Claude Code remember what matters and act on it without being told.
This article covers how these features work, how to use them effectively, and how to combine them for self-improving automation workflows.
Auto Memory: Context That Persists
Before Auto Memory, persisting knowledge between sessions required deliberate effort. You had to write it into CLAUDE.md, create .claude/rules/ files, or use the Memory MCP server. Auto Memory changes the default: Claude now automatically saves useful context as you work.
How It Works
When Claude encounters information likely to be valuable in future sessions, it writes it to an auto-memory file. This happens silently in the background. The saved context includes:
- Project patterns — naming conventions, file organization, architectural decisions
- User preferences — coding style, testing approach, commit message format
- Key file locations — where configuration lives, which files contain business logic
- Debugging solutions — fixes for recurring issues, workarounds for known problems
- Decision rationale — why a particular library was chosen, why a pattern was adopted
You can inspect and manage what has been saved using the /memory command:
# View and edit auto-memory contents
/memory
This opens your auto-memory for review. You can delete entries that are no longer relevant, add clarifications, or restructure the stored knowledge.
How Auto Memory Improves Over Time
The value of Auto Memory compounds. In your first session, Claude starts from scratch. By the fifth session, it already knows your preferred error handling pattern, that your team uses conventional commits, and that the database migration files live in db/migrations/. By the twentieth session, it has built a comprehensive picture of your project.
Session 1: Claude asks about your testing framework
Session 5: Claude remembers you use Vitest with happy-dom
Session 20: Claude knows your test patterns, mock conventions,
and which modules need integration tests vs unit tests
The practical effect is that Claude becomes faster and more accurate the longer you work with it on a project.
Relationship to Existing Memory Systems
Auto Memory does not replace existing memory mechanisms. It complements them:
| System | Purpose | When to Use |
|---|---|---|
CLAUDE.md | Static project policies, tool config | Rules that should never change |
.claude/rules/ | Scoped rules for specific paths | Path-specific conventions |
| Memory MCP | Structured knowledge graph | Team-shared architectural knowledge |
| Auto Memory | Automatic context retention | Everything else — let Claude decide |
Think of CLAUDE.md as your project constitution and Auto Memory as institutional memory that grows organically. You write CLAUDE.md deliberately; Auto Memory accumulates naturally.
Practical Examples
Coding style retention. You correct Claude once: “We use early returns instead of nested if/else blocks in this codebase.” Auto Memory saves this. In future sessions, Claude generates code with early returns without being reminded.
Project-specific conventions. Your team names API handlers with a handle prefix (handleCreateUser, handleDeletePost). After Claude observes this pattern in a few files, Auto Memory retains it.
Debugging solutions. You spend 30 minutes tracking down a CORS issue caused by a misconfigured proxy. Auto Memory saves the root cause and fix. The next time a similar issue arises, Claude already knows the likely culprit.
The /loop Command: Recurring Automation
While Auto Memory handles knowledge persistence, the /loop command handles action persistence. It runs a prompt or slash command at recurring intervals within your session.
Syntax
# Basic syntax
/loop <interval> <prompt or command>
# Examples
/loop 5m check the deploy status on Cloudflare
/loop 10m /run-tests
/loop 15m check if there are new issues labeled "urgent" in the repo
The interval accepts minute notation (5m, 10m, 30m). The default interval is 10 minutes if not specified.
Use Cases
Monitoring deployments. After pushing to production, set up a loop to watch the rollout:
/loop 5m check the deploy status and report any errors from the last 5 minutes of logs
Claude will check at each interval and alert you if something goes wrong.
Periodic code analysis. Run linting or type checking on a schedule while you work:
/loop 10m run typecheck on the src/ directory and summarize any new errors
Health checks. Monitor a service endpoint during development:
/loop 5m curl the /health endpoint on localhost:3000 and report if the response code is not 200
Watching for file changes. Track changes in a directory while collaborating:
/loop 10m check git status and summarize any new or modified files since last check
CI/CD status polling. Watch a GitHub Actions run to completion:
/loop 5m check the status of the latest GitHub Actions run on main and notify me when it completes
Cron Scheduling: Fine-Grained Control
For power users who need more precise scheduling, v2.1.71 also introduced cron scheduling tools. These provide cron-style scheduling for recurring prompts within a session, giving you more control over timing than the /loop command.
Where /loop uses simple intervals, cron scheduling lets you define exact timing patterns. This is useful when you need tasks to run at specific times or with irregular intervals during a long-running session.
Combining Auto Memory and /loop
The real power emerges when Auto Memory and /loop work together. Auto Memory provides the knowledge layer; /loop provides the action layer.
Example: Self-Improving Monitoring
Set up a deployment monitor that gets smarter over time:
/loop 5m check the production logs for errors and suggest fixes based on what you know about this codebase
On the first run, Claude checks logs with generic analysis. But as Auto Memory accumulates knowledge about your typical error patterns, common failure modes, and past fixes, each subsequent check becomes more targeted. Claude starts recognizing patterns: “This looks like the same Redis connection timeout we fixed last week by increasing the pool size.”
Example: Building a Night Shift
Before stepping away from your machine, set up automation to handle routine work:
/loop 10m check for new pull requests, review the diff, and leave inline comments on potential issues
Auto Memory ensures Claude reviews PRs with full knowledge of your project conventions. It knows that your team requires error boundaries around async calls, that database queries should use parameterized statements, and that new API endpoints need corresponding tests.
Example: Continuous Integration Watcher
/loop 5m check CI status for open PRs and summarize any failures with likely root causes
As Auto Memory learns which test failures are flaky, which are environment-related, and which indicate real bugs, the summaries become increasingly useful.
Other Automation Updates Worth Knowing
Several other recent features enhance Claude Code’s automation capabilities:
/copy Interactive Code Block Picker (v2.1.59)
The /copy command now provides an interactive picker for selecting code blocks from Claude’s output. Instead of manually selecting text, you can choose specific blocks to copy to your clipboard.
Improved Compound Bash Command Suggestions (v2.1.59)
Claude now provides better prefix suggestions for compound bash commands, making it easier to chain operations without syntax errors.
Remote Control Subcommand (v2.1.51)
The claude remote-control subcommand enables programmatic interaction with running Claude Code sessions. This opens possibilities for building external tooling and integrations that drive Claude Code from other processes.
claude agents CLI Command (v2.1.50)
The claude agents command provides direct management of agent configurations from the CLI. List, inspect, and manage your agents without digging through configuration files:
claude agents list
Getting Started
If you are already on Claude Code v2.1.71 or later, these features are available now.
Start with Auto Memory. Just use Claude Code normally. After a few sessions, run /memory to see what has been saved. Edit anything that looks incorrect or outdated.
Try a simple /loop. Next time you push a deploy, run:
/loop 5m check if the deploy succeeded
Watch how Claude handles the recurring check, then build from there.
Combine them. Once you are comfortable with both, set up a workflow where /loop handles recurring actions and Auto Memory retains the patterns Claude discovers along the way. Each iteration gets better than the last.
Auto Memory and /loop represent a shift in how Claude Code operates — from a tool you direct moment by moment to a partner that remembers context and acts on schedules. The more you use them together, the more autonomous and effective your workflows become.