Skip to main content

Definition

Assembly: CloudNimble.ClaudeEssentials.dll Namespace: CloudNimble.ClaudeEssentials.Hooks.Tools.Responses Inheritance: System.Object

Syntax

CloudNimble.ClaudeEssentials.Hooks.Tools.Responses.EditToolResponse

Summary

Represents the response payload returned by the Claude Code Edit tool after performing a string replacement in a file.

Remarks

The Edit tool performs exact string replacements in files. It requires that the target file has been read at least once in the conversation before editing. This response is received in the EditPostToolUsePayload when the tool_name is “Edit”. The Edit tool will fail if the EditToolInput.OldString is not unique in the file, unless EditToolInput.ReplaceAll is set to true. Example JSON payload:
{
"filePath": "C:\\Projects\\MyApp\\Program.cs",
"oldString": "Console.WriteLine(\"Hello\");",
"newString": "Console.WriteLine(\"Hello, World!\");",
"originalFile": "using System;\n\nclass Program...",
"structuredPatch": [
{
"oldStart": 5,
"oldLines": 1,
"newStart": 5,
"newLines": 1,
"lines": ["-Console.WriteLine(\"Hello\");", "+Console.WriteLine(\"Hello, World!\");"]
}
],
"userModified": false,
"replaceAll": false
}

Constructors

.ctor

Syntax

public EditToolResponse()

.ctor Inherited

Inherited from object

Syntax

public Object()

Properties

FilePath

Gets or sets the absolute path to the file that was edited.

Syntax

public string FilePath { get; set; }

Property Value

Type: string

Examples

"C:\\Users\\Developer\\Projects\\MyApp\\src\\Program.cs"

Remarks

This is always an absolute path, regardless of whether the original request used a relative or absolute path. On Windows, this will use backslash separators.

NewString

Gets or sets the new string that replaced the old string.

Syntax

public string NewString { get; set; }

Property Value

Type: string

Remarks

This is the replacement text that now appears in the file where EditToolResponse.OldString was previously located.

OldString

Gets or sets the original string that was searched for and replaced.

Syntax

public string OldString { get; set; }

Property Value

Type: string

Remarks

This is the exact string that was matched in the file. The Edit tool preserves the exact indentation (tabs/spaces) from the original file content.

OriginalFile

Gets or sets the complete original content of the file before the edit was applied.

Syntax

public string OriginalFile { get; set; }

Property Value

Type: string

Remarks

This contains the full file content prior to the replacement, which can be useful for implementing undo functionality, auditing changes, or verifying the context of the edit.

ReplaceAll

Gets or sets a value indicating whether all occurrences of the old string were replaced, or just the first occurrence.

Syntax

public bool ReplaceAll { get; set; }

Property Value

Type: bool

Remarks

When false (the default), the Edit tool requires that EditToolResponse.OldString appears exactly once in the file, and only that single occurrence is replaced. When true, all occurrences of EditToolResponse.OldString in the file are replaced with EditToolResponse.NewString. This is useful for renaming variables or updating repeated patterns throughout a file.

StructuredPatch

Gets or sets the structured patch representing the changes made to the file.

Syntax

public System.Collections.Generic.List<CloudNimble.ClaudeEssentials.Hooks.Tools.Responses.StructuredPatchHunk> StructuredPatch { get; set; }

Property Value

Type: System.Collections.Generic.List<CloudNimble.ClaudeEssentials.Hooks.Tools.Responses.StructuredPatchHunk>

Remarks

This contains a unified diff representation showing what changed between the original and edited content. Each StructuredPatchHunk represents a contiguous block of changes. When EditToolResponse.ReplaceAll is true and multiple replacements were made, there may be multiple hunks in the patch, one for each replacement location.

UserModified

Gets or sets a value indicating whether the file was modified by the user since it was last read by Claude.

Syntax

public bool UserModified { get; set; }

Property Value

Type: bool

Remarks

If true, Claude detected that the file content changed between when it was read and when the edit was applied. This can happen if the user edits the file externally while Claude is working. This flag helps track potential merge conflicts or unexpected changes in the editing workflow.

Methods

Equals Inherited Virtual

Inherited from object

Syntax

public virtual bool Equals(object obj)

Parameters

NameTypeDescription
objobject?-

Returns

Type: bool

Equals Inherited

Inherited from object

Syntax

public static bool Equals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

GetHashCode Inherited Virtual

Inherited from object

Syntax

public virtual int GetHashCode()

Returns

Type: int

GetType Inherited

Inherited from object

Syntax

public System.Type GetType()

Returns

Type: System.Type

MemberwiseClone Inherited

Inherited from object

Syntax

protected internal object MemberwiseClone()

Returns

Type: object

ReferenceEquals Inherited

Inherited from object

Syntax

public static bool ReferenceEquals(object objA, object objB)

Parameters

NameTypeDescription
objAobject?-
objBobject?-

Returns

Type: bool

ToString Inherited Virtual

Inherited from object

Syntax

public virtual string ToString()

Returns

Type: string?