Skip to main content

Claude Code Automation: Auto Memory and the /loop Command

How Claude Code's auto memory keeps per-project notes and the /loop command runs recurring tasks, with cron scheduling and examples that combine the two.

Updated October 21, 2026: Corrected the mechanics against Claude Code 2.1.305: auto memory is a per-project memory directory (MEMORY.md plus topic files), a /loop with no interval is self-paced rather than defaulting to 10 minutes, and claude agents opens agent view instead of taking a list subcommand.

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 into the project’s auto memory directory, ~/.claude/projects/<project>/memory/: a MEMORY.md index plus one topic file per memory. 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:

# List memory files, toggle auto memory, open the auto memory folder
/memory

From there you can open the auto memory folder and edit the plain-markdown files directly: delete entries that are no longer relevant, add clarifications, or restructure the stored knowledge. Only the first 200 lines (or 25KB) of MEMORY.md load at the start of each conversation, so Claude keeps the index short and moves detail into topic files.

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:

SystemPurposeWhen to Use
CLAUDE.mdStatic project policies, tool configRules that should never change
.claude/rules/Scoped rules for specific pathsPath-specific conventions
Memory MCPStructured knowledge graphTeam-shared architectural knowledge
Auto MemoryAutomatic context retentionEverything else — let Claude decide

Auto memory is machine-local and shared across every worktree of one repository. Turn it off with the /memory toggle, the autoMemoryEnabled setting, or CLAUDE_CODE_DISABLE_AUTO_MEMORY=1; move it with autoMemoryDirectory.

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: both parts are optional
/loop [interval] [prompt or skill]

# 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

Intervals take s, m, h, and d units, and Claude rounds them to a schedule cron can express. What you leave out changes the behavior:

  • Interval and prompt: your prompt runs on that fixed schedule.
  • Prompt only: Claude picks a delay between one minute and one hour after each iteration, based on what it saw.
  • Interval only, or nothing: Claude runs its built-in maintenance prompt, or your .claude/loop.md if you wrote one.

A scheduled fire only runs skills Claude is allowed to invoke on its own, so built-in commands and skills marked disable-model-invocation: true arrive as plain text instead. Recurring tasks expire seven days after creation, and a session holds at most 50 of them.

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. Ask Claude in plain language and it calls the underlying tools: CronCreate (a 5-field cron expression plus the prompt), CronList, and CronDelete. Schedules are interpreted in your local timezone, and CLAUDE_CODE_DISABLE_CRON=1 turns the scheduler and /loop off entirely.

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 arrived as a way to list configured agents from the CLI. It has since grown into agent view: running it opens a monitor for parallel background sessions, and --json prints the active ones for scripting:

claude agents
claude agents --json

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.

Sources: Claude Code Changelog, Scheduled tasks documentation, Memory documentation