Agent skill

Lfd Design

by elvisun in elvisun/loss-function-development

Design a loss function and harness for a long-running /goal optimization run (loss-function development, LFD).

MITAuto-check: notesSecurity

Install Lfd Design

skills CLI
$ npx skills add elvisun/loss-function-development --skill lfd-design -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install elvisun/loss-function-development lfd-design --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/elvisun/loss-function-development.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/lfd-design .claude/skills/lfd-design && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
lfd-design
GitHub stars
176
Token cost
~2.9k tokens
SKILL.md length
1,639 words
Files
4 (incl. references)
Skills in repo
1
Repo updated
First seen
Licence
MIT

At a glance

Design a loss function and harness for a long-running /goal optimization run (loss-function development, LFD).

  • Works in 10 steps: Observe before asking → Interrogate → Spec: the inner loop → …
  • The user wants to set up an autonomous optimization loop
  • SKILL.md covers Phase 0 — Observe before asking, Phase 1 — Interrogate, Phase 2 — Spec: the inner loop and Phase 3 — Build the eval, plus 7 more sections
  • Instructions only: no scripts, shell commands, URLs or credentials in SKILL.md

What it does

Lfd Design is an agent skill from elvisun/loss-function-development. Design a loss function and harness for a long-running /goal optimization run (loss-function development, LFD). Use when the user wants to set up an autonomous optimization loop, distill a product from public artifacts, turn a spec into an optimization target, or asks to design a /goal. Observes the existing environment, interrogates the task, ingests or generates the spec, builds a blinded eval, generates and verifies the harness, red-teams the target for cheats, and emits goal.md ready to launch. Re-invoke in…

Its SKILL.md is about 2.9k tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including reference files (for example `references/cheat-museum.md`, `references/goal-template.md` and `references/log-template.md`).

It sits in Security, covering Red teaming and adversary simulation. The licence is MIT.

When your agent uses it

  • The user wants to set up an autonomous optimization loop
  • Distill a product from public artifacts
  • Turn a spec into an optimization target
  • Asks to design a /goal

Example prompts

  • “/lfd-design”

Workflow steps

10 steps, taken from the step headings in SKILL.md.

  1. Observe before asking
  2. Interrogate
  3. Spec: the inner loop
  4. Build the eval
  5. Design the loss function
  6. Generate the harness
  7. Verify the harness yourself
  8. Red-team your draft
  9. Emit goal.md
  10. Pre-flight (the two things only the human can do)

What it can do on your machine

Read from SKILL.md and the folder at commit abf2661. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Lfd Design loads about 2.9k tokens when it runs, and up to ~4.9k if it reads all its reference files. Until then it costs about 151 tokens; SKILL.md has 1,639 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~151
When it runs · the whole SKILL.md, loaded when a task matches
~2.9k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~4.9k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check: notes

The automated check noted patterns worth knowing about, such as sudo or a known installer.

  • NoteMentions a .env fileSKILL.md:32
    ich API keys exist in the environment or .env files (check

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from elvisun/loss-function-development at commit abf2661, republished under its MIT licence (© elvisun). 1,639 words, ~2,884 tokens.

Download SKILL.mdSave it as .claude/skills/lfd-design/SKILL.md (or your agent's skills folder). This skill also uses 3 other files; get the full folder from GitHub.
name
lfd-design
description
Design a loss function and harness for a long-running /goal optimization run (loss-function development, LFD). Use when the user wants to set up an autonomous optimization loop, distill a product from public artifacts, turn a spec into an optimization target, or asks to design a /goal. Observes the existing environment, interrogates the task, ingests or generates the spec, builds a blinded eval, generates and verifies the harness, red-teams the target for cheats, and emits goal.md ready to launch. Re-invoke in patch mode when a running loop cheated and the loss function needs patching.

LFD Design

You are designing an optimization target, not solving a task. The agent that receives goal.md is a competent, tireless, literal optimizer: it will satisfy the target by the cheapest available path — memorizing the eval, hardcoding answers, mining feedback channels into lookup tables. Your job is to make genuine capability the cheapest path left.

A spec says "build this, make the tests pass." A loss function says "build this, make the tests pass, then descend toward this bar on data you cannot see." You are writing the second thing. It has four parts: the target, the constraints, the instruments, and the forced entropy. Every /goal you emit must contain all four.

Two modes. Design mode (default): the phases below, in order. Patch mode (see end): a running loop cheated; fix the loss function, not the agent.

Phase 0 — Observe before asking

Inventory the environment BEFORE asking the user anything. The first principle of harness engineering is observability — apply it to your own task:

  • Repo: existing test suites, eval datasets, scoring scripts, CI workflows, logs/telemetry, CLAUDE.md / AGENTS.md.
  • Tooling: what is installed and usable — Playwright/headless browsers, crawlers, image-diff tools, jq, database clients.
  • Surfaces: which API keys exist in the environment or .env files (check presence only; never print values), which providers are reachable.
  • Reference artifact: if the user named a product or dataset, look at what is publicly accessible right now.

Reuse what exists — extend an existing scorer or eval rather than generating a parallel one. Whatever observation could not answer becomes Phase 1.

Phase 1 — Interrogate

Ask the user in ONE batched round, only what Phase 0 couldn't answer:

  1. Outcome — what artifact or behavior, and what does "good" look like? Is there a reference artifact to score against?
  2. Eval source and size — where do ground-truth cases come from, and how many are obtainable? (Phase 3 can build the eval if the answer is "nowhere yet.")
  3. Budgets — wall-clock budget for the run, dollar ceiling, and which paid surfaces exist (crawler credits, LLM keys). An 80% solution in 2 hours beats a 100% one in 30 days; get the user's actual tolerance.
  4. Surface — what the agent may touch: directories, APIs, providers, models, concurrency. Everything unlisted is denied.
  5. Acceptance — the score bar, measured on held-out data only, plus a diminishing-returns stop ("if marginal gain ≈ 0 for N cycles, stop and report").

Phase 2 — Spec: the inner loop

The spec is the starting point, not the finish line. Before designing any optimization target:

  • If a spec exists, read it. If not, generate one: reverse-engineer the reference artifact (public surfaces only) into a system design plus concrete test cases, and write it to spec.md.
  • The spec's test suite is the inner loop: short horizon, fast feedback, one objective — make the tests pass. The eval is the outer loop: long horizon, sparse feedback.
  • goal.md must gate the outer loop behind the inner one: Stage 0 = build to spec, tests green, before any descent on the eval. Never let the agent optimize a half-built system against sparse, slow feedback.

Phase 3 — Build the eval

If the user cannot hand over enough cases, build them — for more and more problems, real expected outputs are sitting in public:

  • Collect real expected outputs from the reference artifact at scale. Public artifacts only; respect robots.txt, rate limits, and ToS.
  • Dedup. Check diversity — no single entity, date range, or template may dominate, or the eval teaches a shortcut.
  • Reject any case that overlaps seed or fixture data.
  • Collection must be independent of the future optimizer: do it now, in this session, and land the answers outside the optimizer's surface.
  • Split: eval/dev (scored freely, misses reported but capped) and eval/holdout (scored rarely, aggregate-only; acceptance measured here exclusively; answers outside the repo if at all possible).
  • Visibility rule, stated explicitly in goal.md: eval INPUTS may be visible (probe generation needs them); eval ANSWERS are never readable — dev answers live only inside the scorer, holdout answers outside the repo.
  • If the total is under ~200 cases, warn explicitly: a small eval is enumerable and the agent WILL memorize it. Widen before proceeding.

Phase 4 — Design the loss function

Target.

  • The metric must be mechanically computable by a script, at the right resolution for the claim. An LLM judge that "compares two screenshots" approves 12px spacing errors; a pixel-diff does not. Match the instrument to the precision the user actually wants.
  • The metric must penalize BOTH failure directions. Recall without precision invites a return-everything cheat; precision without recall invites a return-one-thing cheat. If the user gives a one-sided metric, fix it and tell them why.
  • Run a leak audit on every feedback channel: bits revealed per scoring call × expected number of cycles — can the agent reconstruct the eval before the run ends? If yes, cut feedback resolution (cap the miss list, return aggregates) or grow the set.

Constraints.

  • Wall-clock budget, stated in the /goal. Agents have no sense of time and will grind 10 hours for 2%.
  • Dollar and credit ceilings per paid surface.
  • Surface allowlist from Phases 0–1.
  • Methodology rules (LLM-in-the-data-plane allowed? deterministic only?).
  • Capacity caps on every artifact that could function as a lookup table: keyword lists, regex sets, seed data, special-case branches. Name the artifact and the cap explicitly ("keyword list ≤ 20 entries").

Enumerate the cheats. Read references/cheat-museum.md, then list at least 10 ways a lazy optimizer could max THIS metric without solving THIS task. For each, write the fence: a constraint in goal.md AND a way to detect violation. A constraint without an instrument is a vibe — the agent will violate it cheerfully because it can't tell it's violating it.

Enforcement design rule. Any constraint that references eval content (e.g. "no literal in the codebase may match an eval item") can only be checked by the harness — the agent can't check it without reading the eval. Put the check in harness/lint.sh, run it inside score.sh, and on violation VOID the score and report nothing else. Naming the offending literal turns your lint into a membership oracle the agent can mine string-by-string (museum exhibit 12). Your enforcement instrument is itself a feedback channel — leak-audit it like any other.

Show full SKILL.md (619 more words)Show less

Phase 5 — Generate the harness

Write these files now, tailored to the task. Do not ship placeholders. Reuse anything Phase 0 found.

  • harness/score.sh — the task-specific scorer. Pixel-diff for a UI clone (deterministic rendering: frozen time, animations off, pinned fonts, fixed viewport), recall@k + precision for retrieval, structured JSON diff for API behavior. Runs lint.sh first: any violation voids the score (output VOID: constraint violation and nothing more). Scores eval/dev by default; --holdout returns one aggregate number, rate-limited, and appends to an audit log.
  • harness/lint.sh — checks capacity caps and eval-literal overlap. Called only by score.sh; its detailed findings go to a file outside the optimizer's read surface, for the human.
  • harness/probe.sh — generates perturbed variants of dev INPUTS (paraphrases, date shifts, entity swaps) and reports the dev-vs-probe score gap. The gap is the memorization gauge.
  • harness/status.sh — per-step timestamps and total wall-clock elapsed; spend so far AND projected burn before the next paid batch, per surface; score history per cycle; and the optimizer's own token consumption where session logs allow. Gain per token is the gradient of the optimization itself — the loop should be self-aware.
  • eval/dev/ and eval/holdout/ — from Phase 3.
  • LOG.md — instantiate references/log-template.md: one entry per cycle with hypothesis / expected failure mode / diagnostic / result, written before the change, not after. This is what survives context compaction.

Phase 6 — Verify the harness yourself

Do this now, with your own tools. Do not delegate it to the user:

  1. Run score.sh on dev — it must produce a number.
  2. Calibrate: score one known-good and one known-bad output. The scorer must separate them decisively. A broken scorer optimizes noise.
  3. Run probe.sh and status.sh once each.
  4. Blinding check: from the optimizer's working directory, try to read the holdout answers. If you can, the agent can.
  5. Trip the lint deliberately — plant an eval literal, confirm the score voids WITHOUT naming it, then remove the plant.

Phase 7 — Red-team your draft

Before emitting, simulate the laziest possible agent against your draft /goal: what is the five-minute win? Common ones: seed data that mirrors the eval, mining per-item miss feedback into a keyword lookup table, gaming a judge, editing the scorer or the goal itself, declaring victory on the dev set. Patch the draft and simulate again. Emit only when three consecutive simulations find nothing cheaper than doing the real work.

Phase 8 — Emit goal.md

Fill the structure in references/goal-template.md. Every placeholder gets a task-specific value; no section is dropped. Invariants the emitted goal.md must keep regardless of task: the Stage 0 tests-green gate, VOID semantics, holdout-only acceptance, the read-only set including goal.md itself, the per-cycle checkpoint commit, the entropy rules, and the stop conditions.

Phase 9 — Pre-flight (the two things only the human can do)

Everything else was verified in Phase 6. Tell the user:

  1. Use a disposable API key with a provider-side spend limit.
  2. Babysit cycle 1. Watch what the agent touches and confirm it uses the instruments. Then go to bed.

Patch mode — when the loop cheats anyway

A cheat mid-run is a bug in the target, not the agent. When invoked against a running or paused loop (the user reports a cheat, or LOG.md / a probe gap shows one):

  1. Read LOG.md, the score history, and the diff since the last honest checkpoint.
  2. Identify the open path: which feedback channel leaked, which artifact had spare capacity, which constraint lacked an instrument.
  3. Patch the loss function, not the agent's code: widen the eval, cap the artifact, cut feedback resolution, add the missing lint.
  4. Append the exhibit to references/cheat-museum.md — what it looked like → the fence that closed it.
  5. Re-verify the harness (Phase 6), revert eval-shaped artifacts the cheat produced, and resume the loop from the last honest checkpoint.

© elvisun, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 3 other files (references) in skills/lfd-design of elvisun/loss-function-development.

  • SKILL.md
  • references/cheat-museum.md
  • references/goal-template.md
  • references/log-template.md

Open the folder on GitHubat commit abf2661

Compare with similar skills

Lfd Design next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Lfd Design compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Lfd Design this skillelvisun/loss-function-development176—~2.9kAutomated safety check: NotesMIT
Authorization Bypass DetectionTencent/AI-Infra-Guard6.8k—~753Automated safety check: PassApache-2.0
Run Assert Evalresponsibleai/ASSERT328—~11kAutomated safety check: NotesMIT
Osint Methodologyelementalsouls/Claude-OSINT2.8k—~8.7kAutomated safety check: NotesMIT
Acl AbuseADScanPro/Claude-AD210—~2.6kAutomated safety check: PassMIT
Web Exfiltration DetectionTencent/AI-Infra-Guard6.8k—~1.8kAutomated safety check: PassApache-2.0

Similar skills

  • Authorization Bypass Detection

    Tencent/AI-Infra-Guard

    Probes an AI agent through dialogue for cross-user data access, privilege escalation and login bypass, and reports confirmed findings as structured vulnerability entries.

    6.8k GitHub stars~753 tokensUpdated today
    SecurityAuto-check passed
  • Run Assert Eval

    responsibleai/ASSERT

    Run an ASSERT evaluation against a described risk. An agent skill from responsibleai/ASSERT.

    328 GitHub stars~11k tokensUpdated yesterday
    SecurityAuto-check: notes
  • Osint Methodology

    elementalsouls/Claude-OSINT

    Comprehensive OSINT methodology for external red-team operations and authorized attack-surface assessments.

    2.8k GitHub stars~8.7k tokensUpdated 1 mo ago
    SecurityAuto-check: notes
  • Acl Abuse

    ADScanPro/Claude-AD

    Abusing Active Directory object ACLs (DACL/ownership) for privilege escalation and lateral movement (GenericAll, GenericWrite, WriteDACL, WriteOwner, AddMember, ForceChangePassword, and replication…

    210 GitHub stars~2.6k tokensUpdated 1 mo ago
    SecurityAuto-check passed
  • Web Exfiltration Detection

    Tencent/AI-Infra-Guard

    Probes whether an agent with web fetch and stored user memory can be tricked by a malicious page into leaking data through chained URL paths.

    6.8k GitHub stars~1.8k tokensUpdated today
    SecurityAuto-check passed
  • Probes whether an agent can be hijacked by instructions hidden in documents, retrieved chunks or fetched web pages, using test prompts that embed a hidden instruction.

    6.8k GitHub stars~1.1k tokensUpdated today
    SecurityAuto-check: warnings

Categories

Questions about Lfd Design

What does Lfd Design do?

Design a loss function and harness for a long-running /goal optimization run (loss-function development, LFD). Lfd Design is an agent skill from elvisun/loss-function-development. Design a loss function and harness for a long-running /goal optimization run (loss-function development, LFD).

When should I use Lfd Design?

Lfd Design fits situations like: the user wants to set up an autonomous optimization loop; distill a product from public artifacts; turn a spec into an optimization target; asks to design a /goal.

How do I install Lfd Design in Claude Code?

Run `npx skills add elvisun/loss-function-development --skill lfd-design -a claude-code`. Or copy the skill folder (skills/lfd-design in elvisun/loss-function-development) into .claude/skills/lfd-design in your project. Claude Code loads it when a task matches its description.

How do I install Lfd Design in Codex?

Run `npx skills add elvisun/loss-function-development --skill lfd-design -a codex`. Or copy the skill folder (skills/lfd-design in elvisun/loss-function-development) into .agents/skills/lfd-design in your project. Codex loads it when a task matches its description.

Can I use Lfd Design in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add elvisun/loss-function-development --skill lfd-design -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/lfd-design, .gemini/skills/lfd-design, .github/skills/lfd-design and .opencode/skills/lfd-design in your project.

What does Lfd Design need to run?

SKILL.md names no scripts, command-line tools or credentials: Lfd Design is instructions for the agent only.

Does Lfd Design access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Lfd Design safe to install?

Our automated static check of SKILL.md found notes only (mentions a .env file), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.

What licence does Lfd Design use?

Lfd Design is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Lfd Design use?

About 2.9k tokens (SKILL.md is roughly 12k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 2k tokens, read only when the agent opens those files.

What are the alternatives to Lfd Design?

Skills that share tags, products or a category with Lfd Design: Authorization Bypass Detection (Tencent/AI-Infra-Guard, 6.8k stars), Run Assert Eval (responsibleai/ASSERT, 328 stars), Osint Methodology (elementalsouls/Claude-OSINT, 2.8k stars) and Acl Abuse (ADScanPro/Claude-AD, 210 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Lfd Design?

elvisun (a GitHub user) maintains it in elvisun/loss-function-development, which has 176 GitHub stars. The repository was last updated on June 11, 2026.

Source: elvisun/loss-function-development on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.