organize-elixir-functions
Original:🇺🇸 English
Translated
Organize functions in a file or across a branch.
11installs
Sourcejasonharmongit/jh-skills
Added on
NPX Install
npx skill4agent add jasonharmongit/jh-skills organize-elixir-functionsTags
Translated version includes tags in frontmatterSKILL.md Content
View Translation Comparison →Scope Mode
- File mode: if a file path is provided, only organize that file.
- Branch mode: if no file path is provided, inspect changed files on the current branch and organize files that need updates.
- To see ALL changes made on the branch, always check:
- committed branch-only changes:
git diff --name-status "$(git merge-base HEAD main)"...HEAD - all working tree changes:
git status --short
- committed branch-only changes:
- To see ALL changes made on the branch, always check:
Selection Mode
- Changed-only mode (default):
- only organize candidate functions touched on the current branch
- candidate functions are newly added, renamed, or changed visibility (<->
def)defp - place candidate functions using this skill's ordering rules (see Ordering Rules below), not ad hoc file habits
- do not keep candidate functions anchored near the edit area if that conflicts with proper placement
- do not move untouched function definitions, even if out of order
- Override mode (explicit request only):
- organize all functions in the selected scope, including unchanged definitions
Precedence over file conventions
- These rules outrank local or file-specific habits. If the file clusters related helpers together, keeps private functions near their call sites, or otherwise departs from the ordering below, still place candidate (changed) functions according to this skill.
- Do not preserve a one-off layout for edited code when it conflicts with Ordering Rules (for example, grouping related functions out of typical order). Correct placement for touched definitions takes priority over "staying consistent" with a non-standard arrangement elsewhere in the file.
- In changed-only mode, leave untouched definitions where they are even when the file mixes styles; only moved candidates must follow this skill end-to-end.
Ordering Rules
- LiveView modules:
- use this default callback order: ,
mount/3,handle_params/3,handle_event/3,handle_info/2(and other handlers), thenhandle_async/3render/1 - keep callback groups contiguous, especially ,
handle_event/3, andhandle_info/2handle_async/3 - order clauses alphabetically by event name
handle_event/3 - if is not defined in the module (for example, template-backed LiveViews), skip render-ordering rules
render/1 - private functions last (), sorted alphabetically by function name
defp
- use this default callback order:
- LiveComponent modules:
- use this default callback order: ,
mount/1,update/2,handle_event/3,handle_info/2(and other handlers), thenhandle_async/3render/1 - keep callback groups contiguous, especially and
update/2handle_event/3 - order clauses alphabetically by event name
handle_event/3 - private functions last (), sorted alphabetically by function name
defp
- use this default callback order:
- Non-LiveView modules:
- public functions first (), sorted alphabetically by function name
def - private functions last (), sorted alphabetically by function name
defp
- public functions first (
- Test modules:
- order blocks so the happy path (success) case comes first for a given behavior; place related error-path tests immediately after that happy path (not interleaved with other features)
test - when reordering, keep /
describegroupings consistent with this: success scenario first, then its failure/edge cases in the same clustertest - private functions last (), sorted alphabetically by function name
defp
- order
Structural Safety Rules
- Treat all clauses of the same function name and arity as one unit.
- Preserve existing pattern-match clause order unless explicitly asked to change behavior.
- Keep callback clause groups contiguous (for example, all clauses together).
handle_params/3 - Keep each moved function body unchanged except for location.
- Preserve module structure, comments, spacing conventions, and non-function code.
Output Expectations
- Move each candidate function to its correct ordered position in the file, even when that means crossing the original change area.
- In changed-only mode:
- file mode: if the target file has no candidate functions, make no reordering changes
- branch mode: skip files with no candidate functions and only modify files that need reordering
- In override mode, organize all functions in the selected scope, even if definitions are unchanged.
- Preserve behavior: do not make ordering changes that alter pattern matching outcomes.
- In LiveView and LiveComponent modules, callback lifecycle order wins over alphabetical order.