> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sudocode.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# sudocode feedback relocate

> Manually relocate a stale or outdated feedback anchor to a new line in the spec

## Syntax

```bash theme={null}
sudocode feedback relocate <feedback-id> --line <line-number>
```

## Description

The `feedback relocate` command updates the anchor location of a feedback entry when the original anchor has become stale or inaccurate due to spec changes.

When you relocate feedback:

* A new anchor is created at the specified line
* The original location is preserved in `anchor.original_location`
* Anchor status is set to `"relocated"`
* The `updated_at` timestamp is updated
* Changes are exported to JSONL

Use this command when:

* Feedback shows as stale but content still exists in spec
* Line numbers shifted due to spec edits
* You know the correct new location for the feedback
* Anchor needs manual correction

<Warning>
  Relocation requires you to specify the correct line number. Review the spec content first to ensure accuracy.
</Warning>

## Arguments

<ParamField path="feedback-id" type="string" required>
  The feedback ID to relocate

  **Example:** `FB-004`

  The feedback entry whose anchor needs updating.
</ParamField>

## Options

<ParamField path="--line" type="number" required>
  New line number for the anchor

  **Example:** `--line 50`

  Must be a valid positive integer within the spec's line range.
</ParamField>

## Examples

### Relocate Stale Anchor

Fix a stale anchor by moving it to the correct line:

```bash theme={null}
sudocode feedback relocate FB-004 --line 50
```

<Accordion title="Expected output">
  ```
  ✓ Relocated feedback anchor FB-004
    New location: Error Handling (line 50)
  ```
</Accordion>

### Relocate After Spec Edit

After adding content that shifted line numbers:

<Steps>
  <Step title="Check stale anchors">
    ```bash theme={null}
    sudocode feedback stale
    ```

    Shows FB-004 is stale at original line 38
  </Step>

  <Step title="View spec">
    ```bash theme={null}
    sudocode spec show SPEC-001
    ```

    Find that content is now at line 50
  </Step>

  <Step title="Relocate">
    ```bash theme={null}
    sudocode feedback relocate FB-004 --line 50
    ```
  </Step>
</Steps>

<Accordion title="Expected output">
  ```
  ✓ Relocated feedback anchor FB-004
    New location: Error Response Format (line 50)
  ```
</Accordion>

### Relocate Multiple Anchors

Fix several stale anchors:

```bash theme={null}
sudocode feedback relocate FB-004 --line 50
sudocode feedback relocate FB-007 --line 130
sudocode feedback relocate FB-012 --line 95
```

<Accordion title="Expected output">
  ```
  ✓ Relocated feedback anchor FB-004
    New location: Error Handling (line 50)
  ✓ Relocated feedback anchor FB-007
    New location: Data Validation (line 130)
  ✓ Relocated feedback anchor FB-012
    New location: API Design (line 95)
  ```
</Accordion>

### Invalid Line Number

Attempt to relocate to invalid line:

```bash theme={null}
sudocode feedback relocate FB-004 --line 999999
```

<Accordion title="Expected output">
  ```
  ✗ Failed to relocate feedback
  Invalid line number or line exceeds spec length
  ```
</Accordion>

### Non-Existent Feedback

Attempt to relocate feedback that doesn't exist:

```bash theme={null}
sudocode feedback relocate FB-999 --line 50
```

<Accordion title="Expected output">
  ```
  ✗ Feedback not found: FB-999
  ```
</Accordion>

### JSON Output

Get machine-readable output:

```bash theme={null}
sudocode --json feedback relocate FB-004 --line 50
```

<Accordion title="JSON output">
  ```json theme={null}
  {
    "id": "FB-004",
    "issue_id": "ISSUE-015",
    "spec_id": "SPEC-001",
    "feedback_type": "request",
    "content": "Need clarification on error response format...",
    "agent": "bob",
    "anchor": {
      "line_number": 50,
      "section_heading": "Error Response Format",
      "text_snippet": "Error structure definition",
      "anchor_status": "relocated",
      "original_location": {
        "line_number": 38,
        "section_heading": "Error Handling"
      },
      "context_before": "## Error Response Format\n\nOur API returns errors in a consistent format.",
      "context_after": "All errors include a code and message field.\n\n### Error Codes"
    },
    "dismissed": false,
    "created_at": "2025-10-28T14:30:00Z",
    "updated_at": "2025-10-29T15:20:00Z"
  }
  ```
</Accordion>

Notice:

* `anchor_status` is now `"relocated"`
* `original_location` preserves the original line 38
* New `line_number` is 50
* `updated_at` timestamp reflects the relocation

## What Happens During Relocation

<Steps>
  <Step title="Fetch spec content">
    The spec content is retrieved from the database
  </Step>

  <Step title="Create new anchor">
    A new anchor is generated at the specified line, including:

    * New line number
    * Updated section heading
    * New text snippet
    * Context before/after
  </Step>

  <Step title="Preserve original">
    Original location is saved in `anchor.original_location`:

    * Original line number
    * Original section heading
  </Step>

  <Step title="Set status">
    Anchor status is set to `"relocated"`
  </Step>

  <Step title="Update feedback">
    The feedback entry is updated in the database with new anchor
  </Step>

  <Step title="Update timestamp">
    `updated_at` is set to current time
  </Step>

  <Step title="Export to JSONL">
    Changes are written to `feedback.jsonl`
  </Step>
</Steps>

## Understanding Relocated Status

After relocation, the feedback anchor has `"relocated"` status:

<CardGroup cols={3}>
  <Card title="valid" icon="circle-check">
    **Original anchor**

    * Never moved
    * Content unchanged
    * No original\_location

    Color: Green
  </Card>

  <Card title="relocated" icon="arrows-up-down">
    **Manually updated**

    * Moved to new line
    * Original preserved
    * Intentional update

    Color: Yellow
  </Card>

  <Card title="stale" icon="triangle-exclamation">
    **Needs attention**

    * Content changed
    * Location uncertain
    * Requires relocation

    Color: Red
  </Card>
</CardGroup>

The `relocated` status indicates:

* The anchor was manually updated (not stale detection)
* The original location is preserved for audit trail
* The feedback is now accurately anchored

## Common Workflows

### Fix Stale Anchors

<Steps>
  <Step title="Find stale anchors">
    ```bash theme={null}
    sudocode feedback stale
    ```
  </Step>

  <Step title="Review first stale feedback">
    ```bash theme={null}
    sudocode feedback show FB-004
    ```

    Note the original line and content
  </Step>

  <Step title="View spec">
    ```bash theme={null}
    sudocode spec show SPEC-001
    ```

    Search for the content or section
  </Step>

  <Step title="Identify new line">
    Determine the correct line number where content now exists
  </Step>

  <Step title="Relocate">
    ```bash theme={null}
    sudocode feedback relocate FB-004 --line 50
    ```
  </Step>

  <Step title="Verify">
    ```bash theme={null}
    sudocode feedback show FB-004
    ```

    Check that status is "relocated" and location is correct
  </Step>
</Steps>

### After Major Spec Update

<Steps>
  <Step title="Update spec">
    Make significant changes to specification
  </Step>

  <Step title="Check for stale anchors">
    ```bash theme={null}
    sudocode feedback stale
    ```
  </Step>

  <Step title="Batch relocate">
    For each stale anchor:

    ```bash theme={null}
    sudocode feedback relocate FB-004 --line 50
    sudocode feedback relocate FB-007 --line 130
    ```
  </Step>

  <Step title="Verify all fixed">
    ```bash theme={null}
    sudocode feedback stale
    ```

    Should show: ✓ No stale anchors found
  </Step>
</Steps>

### Calculate New Line After Insertion

If you inserted 10 lines at line 20:

```bash theme={null}
# Original anchor at line 38
# Lines inserted: 10 at line 20
# New line: 38 + 10 = 48

sudocode feedback relocate FB-004 --line 48
```

### Interactive Relocation

Review and relocate interactively:

```bash theme={null}
for fb_id in $(sudocode --json feedback stale | jq -r '.[] | .id'); do
  echo "=== Relocating $fb_id ==="

  # Show feedback details
  sudocode feedback show "$fb_id"

  # Show spec
  spec_id=$(sudocode --json feedback show "$fb_id" | jq -r '.spec_id')
  echo ""
  echo "Spec content:"
  sudocode spec show "$spec_id" | head -50

  # Ask for new line
  echo ""
  echo "Enter new line number (or 'skip'):"
  read line_num

  if [[ "$line_num" =~ ^[0-9]+$ ]]; then
    sudocode feedback relocate "$fb_id" --line "$line_num"
  else
    echo "Skipped $fb_id"
  fi
  echo ""
done
```

## Scripting Examples

### Bulk Relocate with Mapping

If you know the line number changes:

```bash theme={null}
# Map of FB-ID to new line number
declare -A relocations=(
  ["FB-004"]=50
  ["FB-007"]=130
  ["FB-012"]=95
)

for fb_id in "${!relocations[@]}"; do
  line="${relocations[$fb_id]}"
  echo "Relocating $fb_id to line $line"
  sudocode feedback relocate "$fb_id" --line "$line"
done
```

### Calculate Offset Relocation

If all lines shifted by same amount:

```bash theme={null}
# All lines shifted down by 15
offset=15

sudocode --json feedback stale | jq -r '.[] | "\(.id) \(.anchor.line_number)"' | \
while read fb_id old_line; do
  new_line=$((old_line + offset))
  echo "Relocating $fb_id from $old_line to $new_line"
  sudocode feedback relocate "$fb_id" --line "$new_line"
done
```

### Generate Relocation Plan

```bash theme={null}
# Create a plan before executing
echo "Relocation Plan"
echo "==============="

sudocode --json feedback stale | jq -r '.[] |
"FB: \(.id)
Spec: \(.spec_id)
Current Line: \(.anchor.line_number)
Original Line: \(.anchor.original_location.line_number)
Section: \(.anchor.section_heading)
Content: \(.content | .[0:60])...
---"'

echo ""
echo "Review the plan above, then run relocations manually"
```

## Finding the Correct Line

### Method 1: Search by Snippet

```bash theme={null}
# Get the snippet from feedback
snippet=$(sudocode --json feedback show FB-004 | jq -r '.anchor.text_snippet')

# Search spec for snippet
sudocode spec show SPEC-001 | grep -n "$snippet"
```

### Method 2: Search by Section

```bash theme={null}
# Get section heading
section=$(sudocode --json feedback show FB-004 | jq -r '.anchor.section_heading')

# Find section in spec
sudocode spec show SPEC-001 | grep -n "## $section"
```

### Method 3: Manual Review

```bash theme={null}
# Show spec with line numbers
sudocode spec show SPEC-001 | nl -v 1

# Visually find the correct line
```

## Common Questions

<AccordionGroup>
  <Accordion title="Can I relocate an already relocated anchor?">
    Yes, you can relocate feedback multiple times. Each relocation updates the line number but preserves the original location from the first creation.

    ```bash theme={null}
    sudocode feedback relocate FB-004 --line 50  # First relocation
    sudocode feedback relocate FB-004 --line 55  # Second relocation
    ```

    The `original_location` always refers to the first anchor location.
  </Accordion>

  <Accordion title="How do I know what line to relocate to?">
    1. Show the feedback to see the snippet:
       ```bash theme={null}
       sudocode feedback show FB-004
       ```
    2. Search the spec for that content:
       ```bash theme={null}
       sudocode spec show SPEC-001 | grep -n "snippet text"
       ```
    3. Use the line number from grep output
  </Accordion>

  <Accordion title="Can I relocate feedback to a different spec?">
    No, relocation only changes the line number within the same spec. To move feedback to a different spec, you must:

    1. Dismiss the old feedback
    2. Create new feedback on the new spec
  </Accordion>

  <Accordion title="What happens to original_location after multiple relocations?">
    It always preserves the very first location where feedback was created, not intermediate relocations. This maintains the complete history.
  </Accordion>

  <Accordion title="Can I relocate valid anchors?">
    Yes, technically you can relocate any feedback, not just stale ones. But it's usually only necessary for stale anchors. Relocating a valid anchor would change its status to "relocated".
  </Accordion>

  <Accordion title="Is there a way to undo a relocation?">
    Not directly. To undo:

    ```bash theme={null}
    # Get original line number
    orig_line=$(sudocode --json feedback show FB-004 | jq -r '.anchor.original_location.line_number')

    # Relocate back
    sudocode feedback relocate FB-004 --line "$orig_line"
    ```

    However, the status will still show "relocated" not "valid".
  </Accordion>
</AccordionGroup>

## Troubleshooting

<AccordionGroup>
  <Accordion title="Error: Invalid line number">
    **Cause:** Line number is less than 1, not a number, or exceeds spec length

    **Solution:**
    Check spec length:

    ```bash theme={null}
    sudocode spec show SPEC-001 | wc -l
    ```

    Ensure line number is within range:

    ```bash theme={null}
    sudocode feedback relocate FB-004 --line 42
    ```
  </Accordion>

  <Accordion title="Error: Feedback not found">
    **Cause:** The feedback ID doesn't exist

    **Solution:**
    List all feedback:

    ```bash theme={null}
    sudocode feedback list
    ```

    Use correct ID
  </Accordion>

  <Accordion title="Error: Spec not found">
    **Cause:** The spec referenced by feedback doesn't exist

    **Solution:**
    This shouldn't happen if feedback exists. Check database integrity:

    ```bash theme={null}
    sudocode sync
    ```
  </Accordion>

  <Accordion title="Relocation succeeded but anchor still shows as stale">
    **Cause:** Content at new line may not match expected

    **Solution:**
    Verify the new location:

    ```bash theme={null}
    sudocode feedback show FB-004
    ```

    Status should be "relocated", not "stale". If still stale, you may have chosen wrong line.
  </Accordion>

  <Accordion title="Can't calculate correct line number after major spec rewrite">
    **Cause:** Too many changes to accurately map old to new line

    **Solution:**
    Consider dismissing old feedback and creating new:

    ```bash theme={null}
    sudocode feedback dismiss FB-004
    sudocode feedback add ISSUE-015 SPEC-001 \
      --content "Updated feedback..." \
      --line 50
    ```
  </Accordion>
</AccordionGroup>

## Related Commands

<CardGroup cols={3}>
  <Card title="feedback stale" icon="triangle-exclamation" href="/cli/feedback-stale">
    Find stale anchors
  </Card>

  <Card title="feedback show" icon="eye" href="/cli/feedback-show">
    View feedback details
  </Card>

  <Card title="feedback dismiss" icon="check" href="/cli/feedback-dismiss">
    Dismiss feedback
  </Card>

  <Card title="spec show" icon="file-lines" href="/cli/spec-show">
    View spec content
  </Card>

  <Card title="feedback list" icon="list" href="/cli/feedback-list">
    List all feedback
  </Card>
</CardGroup>

## Next Steps

<Steps>
  <Step title="Find stale anchors">
    ```bash theme={null}
    sudocode feedback stale
    ```
  </Step>

  <Step title="Show feedback details">
    ```bash theme={null}
    sudocode feedback show FB-004
    ```
  </Step>

  <Step title="View spec">
    ```bash theme={null}
    sudocode spec show SPEC-001
    ```

    Find correct line number
  </Step>

  <Step title="Relocate">
    ```bash theme={null}
    sudocode feedback relocate FB-004 --line 50
    ```
  </Step>

  <Step title="Verify">
    ```bash theme={null}
    sudocode feedback show FB-004
    ```

    Check status is "relocated"
  </Step>
</Steps>

<Card title="Feedback System Concept Guide" icon="book" href="/concepts/feedback">
  Learn more about the feedback system and anchor management
</Card>
