code-structure-and-modularity
Code structure and module-boundary rubric for writing, extending, reviewing, or reorganizing code.
Skill by ahstn
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ahstn-code-structure-and-modularity
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: writing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/code-structure-and-modularity
What's inside
- Skill name
code-structure-and-modularity- Description
- Code structure and module-boundary rubric for writing, extending, reviewing, or reorganizing code. Use when adding new functionality, choosing where code should live, splitting large files or functions, designing package/module boundaries, reviewing architecture drift, or deciding whether code should be extracted, inlined, grouped, or left together.
- License
- MIT
- Instructions
- 130 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- openai.yaml · agents/
SKILL.md (first lines)
# Code Structure Rubric ## Purpose Use this skill to keep code easy to read, test, modify, and review. Optimize for cohesive responsibilities and clear public boundaries, not for arbitrary line-count reduction. This skill is adjacent to code simplification: simplification improves expression; this rubric improves placement, ownership, encapsulation, and module shape. ## Core Rules - Group code by durable responsibility, domain concept, workflow, or ownership boundary. - Keep public interfaces narrow, named, and stable. Hide implementation details where the language allows it. - Prefer high cohesion and low coupling: things that change together should live together; unrelated reasons to change should be separated. - Use line counts as review triggers, not targets. - Avoid both mega-files and tiny-file scatter. - Preserve behavior, tests, errors, side effects, performance expectations, and external API compatibility unless the task explicitly calls for a breaking change. - Follow local project conventions before applying this rubric generically. ## Function Size - Prefer functions under 60 executable lines. - Functions over 80 executable lines should be easy to scan and justify. - Functions over 120 executable lines require a reason in review. - Functions over 150 executable lines should usually be split. - Functions over 200 executable lines are exceptional. A long function may be acceptable when: - It is linear and low-branching. - It keeps a single coherent workflow together. - Splitting would create navigation-heavy helper chains. - The repeated structure is easier to audit in one place. - It is generated, table-like, parser/state-machine code, or simple dispatch. A shorter function is not automatically better. Do not split solely to reduce line count if the result forces readers through several private helpers that are only meaningful in sequence. ## File and Module Size - Prefer files in the 200-600 line range. - Start questioning files around 800 lines. - Treat 1000 lines as a soft cap. - Files over 1500 lines need clear justification or a split plan. Split files and modules by cohesion and ownership, not by arbitrary symbol count. Related helper types, local utilities, and tightly coupled implementation details may stay together when that makes the code easier to understand. Split when a file contains distinct concepts, unrelated responsibilities, different change cadences, independent test surfaces, or sections that different maintainers would naturally own independently. ## Placement Rubric Before adding code, ask: - What existing module owns this responsibility? - Does this change fit the module's current name and public contract? - Would a future maintainer know to look here? - Does it share data, invariants, lifecycle, or tests with nearby code? - Is it a new domain concept that deserves a named file/module/package? - Would adding it here create a second unrelated reason for this file to change? Prefer adding to an existing cohesive module when the answer is clear. Create or split a module when the current location becomes hard to name, hard to test, or responsible for multiple domains. ## Encapsulation Rubric - Expose the smallest useful public API. - Re-export stable entry points from package/module boundaries when callers depend on them. - Keep private helpers close to the code that uses them. - Avoid generic `utils`, `helpers`, or `common` modules unless the code is truly cross-cutting and has a clear owner. - Avoid cyclic dependencies. If two modules need each other's internals, the boundary is wrong or a third coordinating concept is missing. - Put language/framework adapters at the edges; keep core domain logic independent where practical. ## Splitting Rubric Split when it improves at least one of: - comprehension: the extracted unit has a clear name and responsibility - testability: the extracted unit can be tested independently - ownership: different maintainers or workflows own different parts - change safety: future edits affect fewer unrelated concepts - dependency direction: imports become clearer and less cyclic - reviewability: diffs become easier to inspect without hiding behavior Do not split when: - the new file is just a few lines with no independent concept - readers must jump across many private helpers to understand one workflow - the split only satisfies a line-count preference - the abstraction is speculative - the public API becomes wider or less obvious ## Review Heuristics Before requesting or applying a split, ask: - Can the function's job be summarized in one sentence? - Is the control flow mostly linear? - Are there more than 2-3 nesting levels? - Is cyclomatic complexity above 10 or cognitive complexity above 15-25? - Would a meaningful sub-part benefit from independent unit tests? - Would extracting a helper name a real concept, or just hide a few lines? - Does splitting reduce mental load, or create jump-chasing? ## New Feature Checklist When writing new functionality: - Start by locating the owning domain/module. - Add to the existing module if it remains cohesive and reasonably sized. - Introduce a new file/package only for a named concept, adapter, model family, command, workflow, or boundary. - Keep tests close to the behavior or update the existing test grouping consistently. - Update docs only when public behavior, API, command usage, or architecture changes. - Preserve existing public imports or provide compatibility re-exports when callers may rely on them. ## Refactor Checklist For structural changes: - Separate mechanical moves from behavior changes when possible. - Move code first, then update imports, then run formatting and tests. - Keep exported names stable unless a breaking change is intentional. - Verify no dead imports, duplicate definitions, or orphaned tests remain.
From ahstn/dotfiles, MIT.
More from ahstn/dotfiles
- 0.609score
kubes-mode-v2
ahstn
Personal working mode for software engineering tasks.
SkillAFreshness: A★ 3Claude Code +9 - 0.609score
jira-manager
Jira skill maintainers
Use this skill for all Jira workflows: create epics and issues, transition tickets, add comments, search with JQL, and manage the backlog.
SkillAFreshness: A★ 3Claude Code +9 - 0.606score
computer-use-cua-driver
ahstn
Operate native macOS, Windows, or Linux GUI applications with Cua Driver through an available MCP connection or the installed CLI.
SkillAFreshness: A★ 3Claude Code +9 - 0.606score
code-review-and-quality
ahstn
Reviews staged or unstaged diffs, branches, and GitHub pull requests for defects and material code-health costs.
SkillAFreshness: A★ 3Claude Code +9 - 0.604score
github-librarian
ahstn
Use when looking up GitHub repositories, upstream source, or library internals, either via quick `gh search` queries or by cloning into ~/.cache/github/ for…
SkillAFreshness: A★ 3Claude Code +9 - 0.604score
tty-fork
ahstn
Start a fresh or forked OMP session in a right or below split, or a new tab, in tty7, Herdr, or Tern.
SkillAFreshness: A★ 3Claude Code +9 - 0.603score
slack-message
ahstn
Rules for sending Slack messages and reference request payloads.
SkillAFreshness: A★ 3Claude Code +9 - 0.560score
kubes-mode
ahstn
No description from the publisher yet.
SkillAFreshness: A★ 3Claude Code +9 - 0.557score
personality
ahstn
Draft, edit, or review professional writing in the user's conversational engineering voice.
SkillBFreshness: B★ 3Claude Code +9 - 0.534score
github-yeet
OpenAI
Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request
SkillAFreshness: A★ 3Claude Code +9 - 0.486score
wayfinder
ahstn
Plan a huge chunk of work — more than one agent session can hold — as a shared map of investigation tickets on your issue tracker, and resolve them one at a…
SkillCFreshness: C★ 3Claude Code +9 - 0.484score
grill
ahstn
Interview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree.
SkillCFreshness: C★ 3Claude Code +9
Signals
- Stars
- 3
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jul 24, 2026 (3 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/ahstn/dotfiles
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from ahstn
- 0.609score
kubes-mode-v2
ahstn
Personal working mode for software engineering tasks.
SkillAFreshness: A★ 3Claude Code +9 - 0.606score
code-review-and-quality
ahstn
Reviews staged or unstaged diffs, branches, and GitHub pull requests for defects and material code-health costs.
SkillAFreshness: A★ 3Claude Code +9 - 0.606score
computer-use-cua-driver
ahstn
Operate native macOS, Windows, or Linux GUI applications with Cua Driver through an available MCP connection or the installed CLI.
SkillAFreshness: A★ 3Claude Code +9 - 0.604score
tty-fork
ahstn
Start a fresh or forked OMP session in a right or below split, or a new tab, in tty7, Herdr, or Tern.
SkillAFreshness: A★ 3Claude Code +9 - 0.604score
github-librarian
ahstn
Use when looking up GitHub repositories, upstream source, or library internals, either via quick `gh search` queries or by cloning into ~/.cache/github/ for…
SkillAFreshness: A★ 3Claude Code +9 - 0.603score
slack-message
ahstn
Rules for sending Slack messages and reference request payloads.
SkillAFreshness: A★ 3Claude Code +9
Cite this page
code-structure-and-modularity skill. Agent Mart. https://agentmart.dev/skills/ahstn-code-structure-and-modularity (last updated 2026-10-24)