Skip to content

/diff and /undo slash commands for reviewing and reverting file changes #2504

@carterc8888

Description

@carterc8888

Checked other resources

  • This is a feature request, not a bug report.
  • I searched existing issues and didn't find this feature.
  • I checked the docs and README for existing functionality.
  • This request applies to this repo (deepagents) and not an external package.

Area (Required)

  • deepagents (SDK)
  • cli

Feature description

After the agent makes file edits, there's no quick way to review what changed or revert a bad edit without scrolling through the conversation, running git diff manually, or manually fixing the file.

Two small slash commands would help:

  1. /diff — Show all file changes made by the agent in the current session. Unlike git diff, this only shows agent changes (not manual edits), which is useful when both are mixed. Also works in non-git environments like remote sandboxes.

  2. /undo — Revert the last file edit made by the agent. Validates that the edited text is still present and unique before reverting, so it's safe even if the file was modified after the edit.

Inspired by using Claude Code, which surfaces file changes for easy review. Having the same in Deep Agents CLI would help with trust and transparency.

Proposed solution (optional)

/diff:

  • Extracts all successful edit_file and write_file tool calls from the current thread's messages
  • Generates unified diffs using the existing DiffMessage widget and compose_diff_lines rendering
  • Shows a summary line (e.g. "3 files changed: 2 edits, 1 new file")
  • Filters out failed operations

/undo:

  • Finds the last successful edit_file tool call from the conversation
  • Reverses the edit by swapping old_string and new_string on the filesystem
  • Validates the text is still present and unique before reverting
  • Shows the reverse diff after reverting
  • New file creation (write_file) cannot be undone since the backend has no delete API — communicates this clearly

Both commands are CLI-only (libs/cli/), no SDK changes needed. Reuses existing DiffMessage widget. I have a working implementation with unit tests ready to go.

Additional context (optional)

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliRelated to `deepagents-cli`externalUser is not a member of the `langchain-ai` GitHub organization
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions