The Complete Production SOP: Deploying Agent Scratchpad Step Recorder across Codex, Claude Code, Cursor, and Windsurf
Production SOP to install and run Agent Scratchpad Step Recorder in Codex, Claude Code, and Cursor. Record thoughts and prevent duplicate tool calls.
Technical Overview & Architectural Context
Autonomous coding agents frequently suffer from memory degradation and looping behaviors during complex, multi-turn refactoring operations. When an agent explores a large codebase, it repeatedly executes idempotent reads on the same configuration or source files, re-running expensive AST inspections or file listings because previous discoveries are buried beneath long tool response payloads. Without a structured scratchpad, context windows quickly saturate with raw command outputs, causing context drift and hallucinated file states. The Agent Scratchpad Intermediate Thought & Action Logger (agent-scratchpad-step-recorder) establishes a deterministic working-memory protocol. By forcing the agent to maintain an append-only transaction ledger of its hypotheses, attempted operations, and distillations of tool outputs, the skill eliminates redundant tool invocations. The agent consults its active scratchpad before executing file reads or shell commands, guaranteeing efficient execution trajectories and deterministic milestone transitions.
Prerequisites & Environment Requirements
Verified Search Intents & Long-Tail Queries Solved
This operational tutorial is engineered to provide deterministic solutions for these developer search queries:
Step-by-Step Execution Playbook
Local Environment Setup & SKILL.md Mounting
Mount the SKILL.md specification into your project's agent memory boundary.
Agent runtimes such as Claude Code, Codex, and Cursor scan the repository's `.agents/skills` or `.claude/skills` directory to parse YAML frontmatter instructions. We install the skill manifest into `.agents/skills/agent-scratchpad-step-recorder/SKILL.md` and symlink it to workspace roots where needed.
mkdir -p .agents/skills/agent-scratchpad-step-recorder && curl -fsSL https://askills.dev/api/skills/agent-scratchpad-step-recorder/raw -o .agents/skills/agent-scratchpad-step-recorder/SKILL.md---
name: "agent-scratchpad-step-recorder"
description: "Maintain a structured scratchpad recording agent thoughts, actions, and observations."
metadata:
author: "OpenAI"
version: "1.0.0"
runtime_compatibility:
- "codex"
- "claude-code"
- "cursor"
- "windsurf"
triggers:
- "log agent scratchpad"
- "record intermediate thoughts"
- "prevent duplicate tool calls"
permissions:
fs_read: true
fs_write: "workspace"
shell_exec: false
net_access: false
---Store the active scratchpad state in an ignored path like `.agent/scratchpad.md` to prevent pollution of source code git history.
Ensure that the agent runtime process has write permissions to `.agent/` within the workspace container sandbox.
Scratchpad File Initialization & Git Boundary Setup
Initialize the structured memory ledger file and prevent uncommitted scratchpad churn.
The skill enforces an append-only working memory ledger. To maintain repository hygiene, add the ephemeral scratchpad path to `.gitignore` and initialize the standard four-column markdown table header (Step, Timestamp, Action/Observation, Next Step).
mkdir -p .agent && echo -e "# Agent Working Memory Scratchpad\n| Turn | Hypothesis / Thought | Action / Tool Invocations | Critical Distillation |\n|---|---|---|---|\n" > .agent/scratchpad.md && echo ".agent/scratchpad.md" >> .gitignoreInstruct the agent to store condensed error codes and stack summaries rather than raw stderr dumps to save context tokens.
Do not hardcode sensitive secrets or environment variables inside the scratchpad table.
Intent Matching & Trigger Invocation
Activate the skill deterministically using registered triggers in user prompts.
Agent runtimes check the registered triggers in the skill frontmatter. Invoking prompts containing 'log agent scratchpad' or 'record intermediate thoughts' commands the agent to read `.agent/scratchpad.md` before every reasoning loop and record its trajectory.
Prepend your multi-step prompts with 'record intermediate thoughts and check scratchpad before reading files' for deterministic adherence.
If the agent skips updating the scratchpad, verify that your prompt does not conflict with a top-level system prompt rule forbidding file writes.
Verification, Linting & Output Quality Gate
Validate the scratchpad structure and execute automated verification checks.
Before the agent concludes its execution turn, this quality gate validates that all milestone discoveries were recorded, no duplicate tool calls were made during execution, and that repository unit tests pass cleanly.
test -s .agent/scratchpad.md && git status --porcelainUpon milestone completion, instruct the agent to run a compression sweep on `.agent/scratchpad.md` to prune obsolete trial-and-error rows.
Ensure the agent does not wipe the entire scratchpad prior to verifying that final unit tests exit with code 0.
Real-World Scenario: Multi-Package Dependency Migration & Circular Import Resolution
“Refactor the circular imports between packages/auth and packages/session. Log agent scratchpad, record intermediate thoughts to .agent/scratchpad.md, and prevent duplicate tool calls during module resolution.”
Runtime Troubleshooting & Failure Modes
Root Cause: The agent runtime sandbox restricts file write access outside permitted directory scopes or .agent is read-only.
chmod 755 .agent && touch .agent/scratchpad.md && chmod 644 .agent/scratchpad.mdRoot Cause: The agent failed to consult previous scratchpad entries prior to tool dispatch, causing memory churn.
Add system instruction: 'Before any fs_read tool invocation, agent MUST query .agent/scratchpad.md to verify if the file path has already been parsed.'Frequently Asked Questions (Agent Scratchpad Intermediate Thought & Action Logger SOP)
Q:Can I use Agent Scratchpad Intermediate Thought & Action Logger across Codex, Claude Code, and Cursor simultaneously?
Yes. The SKILL.md specification is fully cross-compatible. All major runtime environments (Codex Desktop, Claude Code CLI, Cursor, and Windsurf) parse the declarative frontmatter and enforce scratchpad tracking rules identically.
Q:How does Agent Scratchpad Intermediate Thought & Action Logger prevent context window overflow during long agent sessions?
Instead of appending full tool responses (like 2,000-line build logs) directly to conversational prompt context, the skill dictates that the agent summarize critical failure signatures into the scratchpad and prune completed milestones.
Q:Does this skill require escalated root or container permissions?
No. The skill operates strictly with fs_read and workspace-scoped fs_write permissions. It carries a Security Score of 98/100, requiring neither root access nor arbitrary network connectivity.
Ready to equip your autonomous agent with Agent Scratchpad Intermediate Thought & Action Logger?
Copy the complete audited SKILL.md specification or download the 1-click zip bundle directly from our verified registry.