with one click
aiclean
// Clean and refactor code with a focus on unnecessary complexity, reducing lines of code, improving readability, and preferring radare2-native portable APIs.
// Clean and refactor code with a focus on unnecessary complexity, reducing lines of code, improving readability, and preferring radare2-native portable APIs.
| name | aiclean |
| description | Clean and refactor code with a focus on unnecessary complexity, reducing lines of code, improving readability, and preferring radare2-native portable APIs. |
When this skill is used:
Read the AGENTS.md for project guidelines first.
Workflow:
clean, cleanup, refactor, simplify, dedup, portable, dead code, reuse.Then improve the code quality following these rules:
bool a = true; instead of bool a; a = true;R_RETURN_* statementsR_API entry points should use R_RETURN_* for programmer-error precondition checksRPanelPos *pos = &p->view->pos; or const ut64 bsz = core->blocksize;UT64_MAX, R_MIN, R_MAX, and COUNTr_strbuf_* or r_str_newf instead of repeated append chains or sprintf/strcat
Use r_read_le* and r_read_be* instead of open-coded byte parsing
Use r_mem_dup, r_list_purge, R_NEWS0, vector/list helpers, RTable, Sdb, and other existing r2 primitives before inventing new helpers_tostring helpers plus one buffered print over many r_cons_printf callssprintf, strcpy, strcat, open-coded endian reads, UB-prone casts, and non-portable format strings
Use <r_types.h> types and PFMT64 macrosPatterns repeatedly seen in radare2 cleanup history:
RStrBuf, then drain once at the endstatic*_tostring style functions to lower RCons pressureslot_off, or local block size, then keep the loop body simplegoto blocks with a bounded for (;;) loop and a retried flagcore->block or file-global structs by reading into local buffers and passing explicit state aroundWhen planning tasks or reviewing code is important to extend the reasoning of the unstaged changes, commits in the current non-master branch and todo roadmap of the ongoing work.
Find bugs and vulnerabilities in C code for radare2
Find logic bugs in C code for radare2 by analyzing control flow, state transitions, and silent assumptions.
Use the bundled r2mcp MCP server for binary analysis, disassembly, and reverse-engineering tasks.
Solve a random TODO or XXX comment
Review source code in commit changes, functions or files and report only high-confidence findings in a structured task-note format.