migrate-layered-function-design
Use when writing or refactoring F# functions whose body mixes abstraction levels, construction details, or implicit invariants that should be isolated behind…
Skill by lamg
Chalk Labs
Need help deploying migrate-layered-function-design?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
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/lamg-migrate-layered-function-design
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: design, 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/migrate-layered-function-design
What's inside
- Skill name
migrate-layered-function-design- Description
- Use when writing or refactoring F# functions whose body mixes abstraction levels, construction details, or implicit invariants that should be isolated behind named steps.
- License
- Apache-2.0
- Instructions
- 127 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Migrate Layered Function Design
## Core principle
A function should be readable as one coherent level of reasoning.
When a function interleaves high-level decisions with lower-level construction details, the reader must understand two programs at once: the algorithm being expressed and the subordinate mechanisms used to express it. Refactor so the outer function states the main argument, while helpers discharge lower-level obligations.
This is not extraction for line count. It is abstraction as a correctness tool: each named helper should capture a meaningful value, decision, invariant, or transformation.
## When to apply
- Apply this when a function body mixes orchestration with parsing, SQL construction, reflection, code generation, validation, or other lower-level mechanics.
- Apply this when several bindings exist only to construct one higher-level value used later.
- Apply this when earlier code establishes an invariant that later code silently relies on.
- Apply this when understanding the main function requires mentally executing an unrelated lower-level algorithm.
## Design rule
- Keep the outer function at the highest useful level of abstraction.
- Move lower-level detail into helpers named for what they establish, not how they happen to compute it.
- Prefer the smallest extraction that makes the reasoning boundary clear.
- Do not hide essential control flow, resource lifetime, transactions, or error handling behind vague helper names.
- Do not introduce public API surface for a local reasoning problem.
## Helper quality
A good helper name lets the caller read as if the result had already been specified.
Good helper names describe:
- a domain value: `buildTablePlan`, `inferPrimaryKey`, `generateViewQueries`
- a decision: `requiresDrainReplay`, `canUseFastPath`
- an invariant: `ensureCompatibleSchema`, `validateMigrationOrder`
- a transformation: `normalizeColumnName`, `quoteSqlIdentifier`
Weak helper names merely repeat mechanics:
- `processItems`
- `handleData`
- `doValidation`
- `getStuff`
- `buildResult`
## Refactoring procedure
1. Identify the result the function is trying to establish.
2. Identify bindings that belong to a lower-level concern than that result.
3. Group the lower-level bindings by the value, decision, or invariant they produce.
4. Extract each group only if its name improves the caller.
5. Keep the helper local if it is only part of this function's proof.
6. Move the helper to a private or internal module only when reuse or testing justifies it.
7. Re-read the outer function and check that it now describes the main reasoning path without forcing the reader into implementation detail.
## Example
Avoid mixing the construction of `V` with the lower-level construction of `E` values:
```fsharp
let f () =
let value0: V = getValue 0
let exp0: E = getExp 0
let exp1: E = getExp 1
let value1: V = joinExps exp0 exp1
value0, value1
```
Prefer naming the lower-level obligation:
```fsharp
let private getValueFromExps () =
let exp0: E = getExp 0
let exp1: E = getExp 1
joinExps exp0 exp1
let f () =
let value0: V = getValue 0
let value1: V = getValueFromExps ()
value0, value1
```
Here `f` speaks in terms of `V`, the value level relevant to its result. The `E` construction is a subordinate concern and belongs behind a name.
If the helper is only meaningful inside `f`, prefer a local helper:
```fsharp
let f () =
let getValueFromExps () =
let exp0: E = getExp 0
let exp1: E = getExp 1
joinExps exp0 exp1
let value0: V = getValue 0
let value1: V = getValueFromExps ()
value0, value1
```
## When not to apply
- Do not extract a helper just because a function is long.
- Do not extract a one-line binding unless the name states a real domain concept.
- Do not split code when the caller still needs to know every detail inside the helper.
- Do not create a helper whose name is less precise than the code it hides.
- Do not obscure sequencing, mutation, disposal, transactions, retries, or error propagation.
- Do not add backward-compatibility wrappers unless there is a concrete persisted, public, or external consumer.
## Relation to module layering
This skill is about reasoning inside functions.
If the same lower-level helpers accumulate across a file and form a reusable responsibility layer, also apply `migrate-layered-module-splitting`.
## Checklist
- Does the outer function now read at one abstraction level?
- Does each extracted helper have a name stronger than its implementation?
- Does each helper establish a value, decision, invariant, or transformation?
- Is the helper placed at the narrowest useful scope?
- Are lower-level details hidden without hiding essential behavior?From lamg/migrate, Apache-2.0.
More from lamg/migrate
- 0.596score
migrate-version-sync
lamg
Version synchronization policy for MigLib and mig CLI packages.
SkillBFreshness: B★ 13Claude Code +9 - 0.546score
migrate-layered-module-splitting
lamg
Use when an F# source file or module mixes stacked responsibility layers whose dependency direction should be made explicit through files, modules, and a…
SkillCFreshness: C★ 13Claude Code +9 - 0.546score
migrate-fsharp-conventions
lamg
F# style rules for the migrate project.
SkillCFreshness: C★ 13Claude Code +9 - 0.481score
migrate-codegen-cpm
lamg
Code generation conventions for `mig codegen` project files.
SkillDFreshness: D★ 13Claude Code +9 - 0.476score
migrate-docs-workflow
lamg
Documentation workflow for design specs and progress tracking in the migrate project.
SkillDFreshness: D★ 13Claude Code +9 - 0.476score
migrate-build-and-test
lamg
Build, test, and install workflow for the migrate project.
SkillDFreshness: D★ 13Claude Code +9
Signals
- Stars
- 13
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Apr 30, 2026 (6 months ago)
- Last release
- Apr 1, 2026 (7 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/lamg/migrate
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from lamg
- 0.596score
migrate-version-sync
lamg
Version synchronization policy for MigLib and mig CLI packages.
SkillBFreshness: B★ 13Claude Code +9 - 0.546score
migrate-layered-module-splitting
lamg
Use when an F# source file or module mixes stacked responsibility layers whose dependency direction should be made explicit through files, modules, and a…
SkillCFreshness: C★ 13Claude Code +9 - 0.546score
migrate-fsharp-conventions
lamg
F# style rules for the migrate project.
SkillCFreshness: C★ 13Claude Code +9 - 0.481score
migrate-codegen-cpm
lamg
Code generation conventions for `mig codegen` project files.
SkillDFreshness: D★ 13Claude Code +9 - 0.476score
migrate-docs-workflow
lamg
Documentation workflow for design specs and progress tracking in the migrate project.
SkillDFreshness: D★ 13Claude Code +9 - 0.476score
migrate-build-and-test
lamg
Build, test, and install workflow for the migrate project.
SkillDFreshness: D★ 13Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get migrate-layered-function-design running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
migrate-layered-function-design skill. Agent Mart. https://agentmart.dev/skills/lamg-migrate-layered-function-design (last updated 2026-10-24)