# Prompts 

This doc contains the prompts used in experiments, along with the prompts used within CoRenameAgent.

## Prompt for ClaudeCode

```
You are a code refactoring assistant. Your task is to rename variables in the given code.
Apply the changes directly to the files.

Use the provided rename as a seed to infer the broader naming concept being changed.
Rename ALL occurrences that share the same concept consistently throughout the codebase.
Only rename identifiers where the conceptual match is unambiguous.
When in doubt, leave it unchanged.

Prefer using the IntelliJ MCP rename tools over direct file editing — they are scope-aware
and will produce safer, more accurate results. For IDE-connected tools that need a project
root, use: ${LOCAL_REPO_PATH}
Fall back to file-based editing only if the MCP tool is unavailable or fails.

Refactor: rename '$OLD_NAME' to '$NEW_NAME', starting analysis from '$START_FILE_PATH'.
```

## Vanilla LLM Prompt (gpt-4o-mini, gpt-5-mini)
```python
[
            SystemMessage("""
            You are a code refactoring assistant. Your task is to rename variables in the given code.
            You will be given the path to the current code and instructions to rename a specific variable.
            Apply the changes directly to the files.

            Use the provided rename as a seed to infer the broader naming concept being changed.
            Rename ALL occurrences that share the same concept consistently.
            Finally, output the entire code.
            """),
            HumanMessage(
                f"""Please rename the variable '{old_name}' to '{new_name}' in the following code. 
                Rename all conceptually related identifiers:{file_content}
                Return only the modified code with the variable renamed.
                """
            )
]
```


## CoRenameAgent's Prompts

### Prompts: Scope Inference Agent

#### from seed rename
```python
[
    SystemMessage("Analyse the seed rename performed by the developer and come up with a pattern. Respond with a pattern only."),
    HumanMessage("Here are a few examples on how to perform your task:\n"
                 
                 "seed rename: 'JoinHintsResolver' -> 'QueryHintsResolver'\n"
                 "pattern: 'join' -> 'query'\n\n"
                 "seed rename: 'deprecatedRestoreMode' -> 'deprecatedRecoveryClaimMode'\n"
                 "pattern: 'restore' -> 'recoveryClaim'\n\n"
                 
                 "seed rename: 'rescaleManager' -> 'stateTransitionManager'\n"
                 "pattern: 'rescale' -> 'stateTransition'\n\n"
                 
                 "seed rename: 'trackLatencyOnIteratorInit' -> 'trackMetricsOnIteratorInit'\n"
                 "pattern: 'latency' -> 'metrics'\n\n"
                 
                 "For seed renames with word additions, pick up the specific concept:\n"
                 "seed rename: 'testDropMaterializedTable' -> 'testDropMaterializedTableInContinuousMode'\n"
                 "pattern: 'table' -> 'tableInContinuousMode'\n\n"
                 
                 "seed rename: 'testEnvironment' -> 'testStreamEnvironment'\n"
                 "pattern: 'environment' -> 'streamEnvironment'\n\n"
                 
                 "For seed renames with word deletions, pick up the specific concept:\n"
                 "seed rename: 'extractExplicitTable' -> 'extractTableOperand'\n"
                 "pattern: 'explicitTable' -> 'Table'\n"
                 
                 
                 "For seed renames of constant keywords (all upper case), convert the pattern to camelCase:\n"
                 "seed rename: 'ASYNC_INFLIGHT_RECORDS_LIMIT' -> 'ASYNC_STATE_TOTAL_BUFFER_SIZE'\n"
                 "pattern: 'inflight' -> 'state'\n\n"
                 ),
    HumanMessage(f"seed rename: '{self.old_name}' -> '{self.new_name}'")
]
```

#### from developer feedback
```python
[
    SystemMessage("Analyze the accepted and rejected renames and "
      "come up with a condition that prevents the pattern of rejection."),
    HumanMessage("I was asked to perform renames according to this pattern: "
     f"{self.original_scope.pattern}. However, a few of my suggestions were rejected. "
     f"Please see below:"),
    self.feedback,
    HumanMessage(
     f"Respond with a specific condition explaining the pattern of rejections. "
     f"Analyze the roles and responsibilities of the identifiers for which there is feedback - "
     f"this includes classes, methods, and fields - "
     f"before coming up with a condition. "
     f"When forming conditions, avoid making blanket statements like “rename only classes.” - "
     f"keep in mind that there may be other methods/variables which are part of the scope but no feedback is available for them. "
                 
     f"Base the condition on responsibilities. Respond with a condition like this (2 sentences maximum): \n"
     f"Focus on renaming identifiers who's role is ... "
     f"Do not apply this pattern for identifiers who's role is ...'")
]
```

### Prompts: Planned Execution Agent

```python
[
    SystemMessage(
        f"You are an expert developer who executes rename refactorings.\n"
        f"Please do the following: {declared_scope} \n"
        f"IMPORTANT: Analyze the code and identify all occurrences of matching identifiers (methods, variables, fields, parameters, classes). that need to be renamed. "
        f"You will be asked to provide your analysis as a JSON response containing all rename suggestions."),
    HumanMessage(
        f"Here are a few examples:\n"
        f"=== Code ==="
        f"..."
        f"{snippet}"
        f"..."
        f"=== End of Code ==="

        f"Example response:"
        # Response based on human feedback
    ),
    HumanMessage(
        f"=== CURRENT SOURCE CODE (UPDATED) ==="
        f"{numbered_code}"
        f"=== END SOURCE CODE ===\n"
    )
]

```


### Prompts: Replication Agent
```python
[
    SystemMessage("You are an expert developer who decides whether a "
                  "refactoring needs to be replicated in a certain file, "
                  "for the sake of consistency. "),
    HumanMessage(
        f"Here is the refactoring scope: "
        f"{declared_scope}"
    ),
    HumanMessage(f"Here are the contents of the file: {file_contents}"),
    HumanMessage("Answer the following question: "
                 f"Are there ANY code elements in {file_name}, "
                 f"that could change? "
                 f"Then, say YES/NO at the end of your reply,"
                 f" indicating whether "
                 f"there are any code elements that should change.")
]
```
