agentleFS
cyberkaidacyberkaida/reverse-engineering-assistant/src/CLAUDE.md

reverse-engineering-assistant / src

CLAUDE.md848 starsChanged 13 months agoApache-2.0View on GitHub

This file provides guidance for Claude Code when working with the ReVa source code. This is the top-level documentation for the src/ directory structure. Use JUnit 4 for all Java tests: ALWAYS use AddressUtil.formatAddress(address) for consistent address formatting in JSON output:

The file

We split this CLAUDE.md into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use Function.getParameters() and Function.getAllVariables() to verify variable changes

    line 43
  2. Very specific:

    Use DataType.isEquivalent() to compare datatypes before/after modifications

    line 44
  3. Distinctive:

    Use JUnit 4 for all Java tests:

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md - Source Directory Overview

This file provides guidance for Claude Code when working with the ReVa source code. This is the top-level documentation for the src/ directory structure.

Quick Reference

ItemValue
MCP SDK Versionv1.1.1
Jackson Version2.21.x
Jetty Version11.0.26
PyGhidra Version3.1.0+
JUnit VersionJUnit 4 (NOT JUnit 5)
Build Commandgradle (NOT ./gradlew)
Unit Testsgradle test
Integration Testsgradle integrationTest
Python Testsuv run pytest

Directory Structure

DirectoryPurposeDocumentation
main/java/reva/Java extension codeSee package-level CLAUDE.md files
test/Java unit tests (no Ghidra env)Fast tests for utilities/logic
test.slow/Java integration tests (GUI required)test.slow/CLAUDE.md
reva_cli/Python CLI for stdio transportPython package for mcp-reva

Testing Guidelines

Test Types and Locations

Test TypeLocationRequirementsCommand
Java Unittest/No Ghidra environmentgradle test
Java Integrationtest.slow/GUI environment, fork=1gradle integrationTest
Python Unittests/ (marker: unit)Mocked PyGhidrauv run pytest -m unit
Python Integrationtests/ (marker: integration)PyGhidra availableuv run pytest -m integration
Python E2Etests/ (marker: e2e)Full CLI subprocessuv run pytest -m e2e

Critical Integration Test Requirements

  • ALWAYS validate actual Ghidra program state changes, not just MCP responses
  • Use Function.getParameters() and Function.getAllVariables() to verify variable changes
  • Use DataType.isEquivalent() to compare datatypes before/after modifications
  • Tests require java.awt.headless=false and forkEvery=1
  • You are not finished until all tests pass!

JUnit Version

Use JUnit 4 for all Java tests:

// CORRECT - JUnit 4
import org.junit.Test;
import org.junit.Before;
import org.junit.After;

// WRONG - JUnit 5 (causes compilation errors)
import org.junit.jupiter.api.Test;           // DO NOT USE
import org.junit.jupiter.params.ParameterizedTest; // DO NOT USE

Address Formatting

ALWAYS use AddressUtil.formatAddress(address) for consistent address formatting in JSON output:

import reva.util.AddressUtil;

// CORRECT - Consistent "0x" prefix
String formatted = AddressUtil.formatAddress(address);
// Returns: "0x404000"

// WRONG - Inconsistent format
String wrong = address.toString(); // May not have "0x" prefix

Decompiler Tool Implementation

Adding New Tools to DecompilerToolProvider

StepAction
1Create register[ToolName]Tool() method following existing patterns
2Call it from registerTools() method
3Use HighFunctionDBUtil.updateDBVariable() for persisting variable changes
4Follow the rename-variables pattern for consistency
5Handle decompilation with proper error handling and transaction management

Key Decompiler APIs

APIUsage
DataTypeParserUtil.parseDataTypeObjectFromString()Parse datatype strings ("char*", "int[10]")
HighFunctionDBUtil.updateDBVariable()Persist variable changes to database
DecompInterfaceGet decompiled function (ALWAYS dispose!)
LocalSymbolMap.getSymbols()Returns Iterator (use while loop, not for-each)

Common Patterns

// Transaction management for all program modifications
int txId = program.startTransaction("Tool operation");
try {
    // Perform modifications
    program.endTransaction(txId, true);
} catch (Exception e) {
    program.endTransaction(txId, false);
    throw e;
}

// Decompiler disposal pattern
DecompInterface decompiler = new DecompInterface();
try {
    decompiler.openProgram(program);
    DecompileResults results = decompiler.decompileFunction(function, 30, null);
    if (!results.decompileCompleted()) {
        return createErrorResult("Decompilation failed: " + results.getErrorMessage());
    }
    // Process results...
} finally {
    decompiler.dispose(); // ALWAYS dispose to prevent memory leaks
}

// LocalSymbolMap iteration (NOT Iterable!)
Iterator<HighSymbol> symbolIter = localSymMap.getSymbols();
while (symbolIter.hasNext()) {
    HighSymbol symbol = symbolIter.next();
    // Process symbol
}

Parameter Handling

Use AbstractToolProvider helper methods for type conversion and validation:

// Required parameters (auto-converts types)
String programPath = getString(request, "programPath");
int count = getInt(request, "maxCount");

// Optional parameters with defaults
int startIndex = getOptionalInt(request, "startIndex", 0);
boolean verbose = getOptionalBoolean(request, "verbose", false);

// Exception handling is automatic - registerTool() wraps handlers
// to catch IllegalArgumentException and ProgramValidationException

Critical Utility Usage

ALWAYS use ReVa utilities instead of direct Ghidra APIs:

UtilityMethodPurpose
AddressUtilformatAddress()REQUIRED for all address formatting in JSON
ProgramLookupUtilgetValidatedProgram()REQUIRED for program resolution with helpful errors
AbstractToolProvidergetProgramFromArgs()REQUIRED for tool parameter extraction
DataTypeParserUtilparseDataTypeObjectFromString()Parse datatype strings
HighFunctionDBUtilupdateDBVariable()REQUIRED for persisting variable changes
SymbolUtilisDefaultSymbolName()Filter Ghidra-generated names

Troubleshooting

Common Build Issues

ProblemSolution
Jackson conflictsRun rm lib/*.jar and rebuild
JUnit 5 compilation errorsReplace with JUnit 4 annotations
Integration tests failEnsure java.awt.headless=false
Tests interfere with each otherEnsure forkEvery=1 in build.gradle
Gradle wrapper not foundUse gradle directly, not ./gradlew

Common Runtime Issues

ProblemSolution
Memory leaksAlways dispose DecompInterface instances
Program not foundUse ProgramLookupUtil.getValidatedProgram() for helpful errors
Transaction errorsAlways use try-finally for startTransaction/endTransaction
Iterator exceptionsCheck API - LocalSymbolMap.getSymbols() returns Iterator, not Iterable

Related Documentation

Essential Infrastructure

  • util/CLAUDE.md - Foundational utilities (AddressUtil, ProgramLookupUtil, etc.)
  • plugin/CLAUDE.md - ConfigManager, plugin lifecycle
  • server/CLAUDE.md - MCP server architecture

Tool Providers

  • tools/CLAUDE.md - Tool provider patterns and base classes
  • tools/decompiler/CLAUDE.md - Decompiler tools
  • tools/functions/CLAUDE.md - Function analysis tools

Testing

  • test.slow/CLAUDE.md - Integration test base class and patterns

Supporting Systems

  • resources/CLAUDE.md - MCP resource providers
  • services/CLAUDE.md - Service interfaces
  • headless/CLAUDE.md - Headless mode support

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.