Command Palette

Search for a command to run...

Назад к скиллам
скилл № 57348

aiclean

Clean and refactor code with a focus on unnecessary complexity, reducing lines of code, improving readability, and preferring radare2-native portable APIs.

БесплатноБез исполняемых скриптов
radareorgот radareorg★ 23 звезды на GitHub

Установить aiclean в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

When this skill is used:

Read the AGENTS.md for project guidelines first.

Workflow:

  1. Check the whole change: the branch diff against its merge-base plus any uncommitted work, and the functions or URLs given as context. Code already committed on the branch is still unreviewed; a scope given by the invoker narrows within that diff, never below it.
  2. Analyze the files involved and take a list of common coding practices from the project.
  3. Inspect recent cleanup-oriented history in the same subsystem before patching. Search for commits using terms like clean, cleanup, refactor, simplify, dedup, portable, dead code, reuse.
  4. Search for an existing API before polishing any new walk, parse, or traversal. Grep libr/include/ for _foreach, _recurse, _dfs, _iter and check the cmd_*.inc.c help tables; deleting new code in favor of an existing API is the best cleanup. Grep the patched file too, for how it already expresses the same thing; matching the local idiom is usually cheaper than any new helper.
  5. Create a small plan that favors behavior-preserving simplification, LOC reduction, and safer ownership/bounds handling. Sweep every new or changed construct (each struct, loop, string test, arithmetic expression, null check, and duplicated block) against the rules below rather than only the obvious spots — maintainer review nitpicks tend to hit the constructs a quick pass skips. Apply a fix that is about a concept at every call site of that concept, not only at the one that surfaced it.
  6. Validate with focused tests or builds for the touched area when feasible. Keep one case where the change must be inert (the other config value, the input outside the predicate) and check it is green on base and branch; two cases that fail for the same mutation are one case. Prove each behavior in the diff is tested: break it (invert the condition, drop the write, return early), name the test that fails, then restore the code before the next one; a behavior no test catches is untested however many tests pass. Check the mutation hits that behavior and nothing else, or its result means nothing. Write new tests against a synthetic fixture (malloc:// plus wx) rather than a real binary plus full analysis, whose output differs between hosts, and assert semantic fields instead of absolute character offsets, which move with unrelated strings.

Then improve the code quality following these rules:

  • Reduce double dereferences by caching pointers as local variables
  • Define and assign variables in the very same line if possible Prefer bool a = true; instead of bool a; a = true;
  • Use the correct type for variables and return types. f.ex: use bool instead of int when possible values are 0 or 1.
  • Return the comparison itself instead of cond? 1: 0, and mark a small file-local predicate static inline
  • Give new locals and test functions descriptive names; on, lead or f4 make the reader recover the meaning from the body
  • Read a value the caller already holds (a loaded table, a precomputed set, block or function membership) instead of recomputing or re-parsing it
  • Open each binary once per set of arguments: fold commands on the same file and ARGS into one r2r case instead of one case per command
  • Use R_STR_ISEMPTY (s) / R_STR_ISNOTEMPTY (s) for empty-or-null string tests instead of !s || !*s / s && *s
  • Order struct fields widest-first (pointers and 64-bit types, then 32-bit, then bool/char last) so the compiler inserts no padding
  • Prefer a heap char * (strdup, r_str_newf) over a fixed char buf[N] when the string length is unbounded (type, symbol, or user-supplied names); fixed buffers silently truncate
  • Parenthesize sub-expressions in mixed-operator arithmetic, e.g. ((ut64)i * stride) + (off / size), so precedence is explicit
  • Prefer small, surgical patches over broad rewrites
  • Preserve behavior first; when cleanup changes behavior, back it with tests or clear bug evidence
  • Identify repeated logic that can be unified
  • When 2 or more paths perform the same walk, parse, or format, extract a helper/table/callback instead of keeping copy-pasted branches
  • Extract the shared tail into one helper when two loops differ only in their up-front filtering
  • Collapse varargs wrappers that forward to the same va_list worker differing only in a constant into one function plus one-line macros
  • Fold if blocks that differ only in data into one loop over a static table
  • Replace parallel candidate fields or fallback branches with a small array plus a loop
  • Keep a flat membership test as a switch with fallthrough cases; a table plus a scan loop is for branches that carry differing data
  • Skip pure style calls; only propose changes with a real LOC or readability win
  • Mention code you examined and left alone; some functions are as long as they need to be
  • Be positive for if/else the conditionals (if must be the true/valid case)
  • Flatten ne
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл aiclean?

Clean and refactor code with a focus on unnecessary complexity, reducing lines of code, improving readability, and preferring radare2-native portable APIs.

Как установить скилл aiclean?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл aiclean запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить aiclean с