Why Coding Agents Hallucinate APIs and Skip Tests — And How Agent Skills Fix It

    This article examines three common failure modes of AI coding agents: inventing APIs that do not exist, changing features without ever running tests, and confidently declaring a task "done" without any verification evidence. Rather than reviewing individual products, it breaks down an approach gaining traction in the open-source community: packaging engineering methods as versionable Skills assets. You will learn the standard structure of a skill package, a three-layer format with progressive loading that keeps dozens of skills available without exhausting the context window, how to adapt skills across different coding tools, a one-click installation script, and how to self-test and evaluate skills so an agent moves from looking capable to verifying its work and admitting when it does not know.

    1. Background: Three Chronic Problems with Vibe Coding

    Describing requirements in natural language and letting an AI coding tool generate and modify the code — often called “vibe coding” — has dramatically lowered the barrier to development. The experience gap, however, is just as obvious. An agent can produce several hundred lines of code in one pass without ever running the project, confidently declare the work “complete” with no verification behind it, and when a requirement is ambiguous, instead of asking, quietly “fills in” its own business rules and may even call interfaces that do not exist.

    The community tends to summarize this as three chronic problems: guessing, not testing, and blind trust. They look like model capability issues, but the root cause is the collaboration model: the model does not know the team’s coding conventions, does not know which verification methods are available to it, and has never been required to provide evidence for its conclusions.

    One phenomenon is worth attention: the open-source community is mitigating these problems with a lightweight approach called Skills. Related projects use Markdown and scripts as their vehicle, have accumulated more than 20,000 stars, and are being wired into a wide range of AI coding tools by developers. The idea is not mysterious — it is the old software engineering practice of making tacit experience explicit. Experience that lives only in a senior engineer’s head is passed down by word of mouth, and newcomers can only relearn it through repeated trial and error. Once it is written down as conventions, templates, checklists, and automation scripts, everyone can reuse it and keep iterating on it.

    Skills are the assetization of this experience: writing down “how a senior engineer actually does this” so the agent can automatically retrieve it at the right moment and follow it. This approach has been validated by a large number of developers in the open-source community. The sections below break down its design logic and how to put it into practice.

    2. What Agent Skills Are: Reusable “Method Packages”

    2.1 Definition and positioning

    A skill packages the methodology for a class of tasks into structured text plus supporting scripts, as an asset the agent can load on demand. It is not the same as:

    • Prompt templates — templates must be pasted manually, and the background has to be re-explained every time.
    • Knowledge base documents — documents wait passively to be retrieved; they do not prescribe steps and are not enforced.
    • External tool interfaces — tools provide the capability of “what to do”; a skill defines when to use it, in what order, and what counts as finished.

    The three are complementary rather than substitutes. The value of a skill lies in composability: one skill can call multiple tools and reference multiple conventions, while remaining plain text that is easy to read, review, and version.

    2.2 The three-layer structure

    A mature skill package usually consists of three layers:

    Layer What it holds When it enters the context
    Metadata layer Name, applicable scenarios, trigger-condition description Always present, summary only
    Instruction layer Workflow, decision rules, checklists, counter-examples Loaded once the task matches
    Resource layer Convention docs, code templates, examples, verification scripts Read on demand when execution reaches a specific step

    2.3 Key mechanism: progressive loading

    If every conversation stuffed all conventions into the context, you would quickly hit the model’s window limit, costs would rise, and attention would be diluted. Skills instead follow a logic similar to on-demand paging in an operating system:

    1. In the normal state, only each skill’s metadata summary is exposed;
    2. When a task matches the description, the full instructions are loaded;
    3. When details are needed, reference material inside the skill is read or its scripts are executed.

    This way, dozens or even hundreds of skills can coexist without consuming a large amount of context all at once.

    2.4 Differences from traditional approaches

    Compared with concentrating conventions in a single global instruction file, skills offer:

    • Scenario isolation — backend API design and frontend page refactoring each hold their own conventions without interfering with each other;
    • On-demand reach — a clear description of “when to use this” reduces interference from irrelevant content;
    • Independent evolution — each skill carries its own version and owner, so changes do not affect other skills.

    3. Root Causes of the Three Chronic Problems and How to Break Them

    3.1 Guessing: the reflex to fill gaps when information is missing

    Models are repeatedly trained to “give a complete answer,” so when information is ambiguous they lean toward filling it in themselves rather than stopping to ask.

    The fix is to make “align first” a hard format requirement. The agent must output the following before doing any work:

    1. [Goal] Restate this task in one sentence
    2. [Assumptions] Information you have filled in yourself (list each item)
    3. [Open questions] Key issues that affect the approach (no more than 3)

    Take “add an export feature to the order list” as an example. The agent proactively asks: which fields to export, the limit for a single export, asynchronous or synchronous, whether permission checks are needed. Disagreements like these usually surface only after something breaks in production; here they surface before work starts.

    3.2 Not testing: a missing feedback loop

    The default behavior of many agents is “deliver as soon as it is written.” When the only marker of completion is “code is written,” of course there is no motivation to verify.

    The fix works on two fronts:

    • Scripted verification — turn “runnable, testable, statically checkable” into one repeatable command, with the script producing real results instead of the model’s verbal claim;
    • Definition of done — make it explicit that only a passing verification counts as done; on failure, enter a repair loop rather than reporting success.
    1. #!/usr/bin/env bash
    2. # verify.sh: single verification entry point; abort immediately if any step fails
    3. set -euo pipefail
    4. cd "$(dirname "$0")/../.."
    5. echo "[1/4] Installing dependencies..."
    6. npm ci
    7. echo "[2/4] Static checks..."
    8. npm run lint
    9. echo "[3/4] Type checking..."
    10. npm run typecheck
    11. echo "[4/4] Unit tests..."
    12. npm test -- --coverage
    13. echo "All verification checks passed"

    The key here is the single entry point: the agent and the human both call the same command, so the verification standard does not drift depending on who runs it.

    3.3 Blind confidence: conclusions without evidence

    Large models tend to produce fluent, definitive statements, and fluency does not equal correctness.

    The fix has two parts:

    • Require evidence — any conclusion of “done” or “fixed” must be accompanied by the commands actually executed and their real output;
    • Distinguish status — label each conclusion as verified / not verified / speculation only, and state the reason honestly for anything not verified, for example a missing test environment or a need for human confirmation.

    4. The Standard Structure of a Skill Package

    Take a “feature development” skill as an example. A typical layout looks like this:

    1. my-skills/
    2. ├── feature-dev/
    3. │ ├── SKILL.md # metadata + workflow + rules
    4. │ ├── checklist.md # pre-delivery checklist
    5. │ ├── templates/
    6. │ │ └── report.md # reporting template
    7. │ └── scripts/
    8. │ └── verify.sh # single verification entry point
    9. ├── bugfix/
    10. │ └── SKILL.md # defect fixing: reproduce -> locate -> minimal fix -> regression
    11. └── code-review/
    12. └── SKILL.md # review: convention consistency, edge cases, security risks

    Here is a sketch of how SKILL.md might be written (the exact field format depends on the loading convention you adopt):

    1. ---
    2. name: feature-dev
    3. description: Use for adding or modifying business features. Align requirements and assumptions first, then implement and verify with tests, then report in a fixed format.
    4. ---
    5. ## Applicable scenarios
    6. - Adding interfaces, pages, or data-processing logic
    7. - Modifying existing business behavior
    8. ## Not applicable
    9. - Copy or config-only changes (the lightweight flow is enough)
    10. - Purely advisory questions (answer directly)
    11. ## Workflow
    12. 1. Align: output [Goal], [Assumptions], [Open questions]; wait for the user to confirm key ambiguities
    13. 2. Investigate: read the relevant code and the conventions under references; define the scope of the change
    14. 3. Plan: list the change points and impact surface, and state what will not be modified
    15. 4. Implement: make changes in small steps, keeping it runnable at each step
    16. 5. Verify: run scripts/verify.sh; enter the repair loop on failure
    17. 6. Report: output conclusions and evidence per templates/report.md
    18. ## Hard rules
    19. - Never invent non-existent interfaces, parameters, or file paths; state uncertainty when you cannot determine them
    20. - Do not pad results with "fake tests" (assertions that do not check behavior)
    21. - Every "passed" in the report must come from real script output

    5. Wiring Skills into Mainstream Coding Tools

    Quite a few coding tools on the market support custom instructions and extension mechanisms, and the loading methods differ. There are three common patterns:

    1. Convention-based directory scanning — the tool automatically scans a designated directory in the project at startup and picks up the skill files there.
    2. Explicit reference — in a global or project-level instruction file, state where the skills directory lives and how it should be loaded.
    3. Script hooks — trigger a script at a specific lifecycle point to handle syncing, validation, or packaging.

    For cross-tool reuse, it is worth designing skills in a tool-agnostic standard format: write the body in plain Markdown, keep scripts dependent only on common runtimes, and make capability calls through the external tool-invocation mechanism common to each tool. Then switching tools means adjusting only the loading configuration, with no need to rewrite the skill content.

    A reusable “one-click install” script looks like this, with path mappings added for the target tool as needed:

    1. #!/usr/bin/env bash
    2. # install-skills.sh: install the skill packages into the project's conventional location
    3. set -euo pipefail
    4. SRC_DIR="$(cd "$(dirname "$0")" && pwd)"
    5. TARGET_DIR="${1:-.agent/skills}"
    6. mkdir -p "$TARGET_DIR"
    7. find "$SRC_DIR" -mindepth 2 -maxdepth 2 -name "SKILL.md" -print0 |
    8. while IFS= read -r -d '' skill_file; do
    9. skill_dir="$(dirname "$skill_file")"
    10. skill_name="$(basename "$skill_dir")"
    11. dest="$TARGET_DIR/$skill_name"
    12. rm -rf "$dest"
    13. cp -r "$skill_dir" "$dest"
    14. echo "Installed skill: $skill_name"
    15. done
    16. echo "Done. Skills directory: $TARGET_DIR"

    The script does three things: automatically discover all skills, copy them by name into the target directory, and overwrite old versions to keep things consistent. Hook it into the project’s initialization flow, have each team member run it once after pulling the code, and everyone gets a uniform skill environment.

    6. Making Skills Actually Work: Self-Testing and Evaluation

    A finished skill is not necessarily an effective skill. At least two layers of verification are recommended.

    The first layer is skill self-testing: test a skill the way you test code. Take a fixed set of tasks, run them with the skill enabled and with it disabled, and compare the difference:

    • Did it proactively raise clarifying questions?
    • Did it run the verification script?
    • Did the report contain evidence?
    • How many rounds of rework and how much human intervention?

    The second layer is folding skills into the development process:

    • Versioning — commit skills alongside the codebase and put changes through review;
    • Observability — record how often a skill is triggered and the verification failure rate, and use that as a basis for optimization;
    • Layered maintenance — team-level skills hold general conventions, project-level skills hold specific business conventions, keeping the two from polluting each other.

    7. Common Misconceptions

    1. Longer skills are better — piling on too many rules dilutes the key points; one skill should focus on one class of task.
    2. Vague trigger descriptions — the description determines the hit rate; a vague one either never loads or loads when it should not.
    3. Treating skills as a panacea — skills constrain behavior but cannot replace human judgment; key decisions still need human confirmation.
    4. Non-reproducible verification scripts — scripts that depend on a local machine environment distort conclusions; they should also run in a clean environment.
    5. Writing secrets into skills — API keys, internal addresses, and the like should not appear in skill files; inject them via environment variables or a configuration service.

    8. Extending to Enterprise Adoption

    For enterprise scenarios, skills can be operated as team knowledge assets: manage the skills repository centrally, wire it into code review and change auditing; run execution environments on an elastic container platform to guarantee consistency; and aggregate verification results, durations, and failure reasons into logging and monitoring/alerting systems to form a “skills usage -> effect measurement -> continuous optimization” loop. On that foundation, teams can gradually build their own library of methodology assets, so new members and new projects can directly reuse accumulated experience.

    9. Conclusion

    The ceiling of AI coding tools depends not only on the model itself, but on how we convey methods and constraints to it. The core of the skill-based approach is translating “a senior engineer’s experience” into steps the agent can execute, rules it can check against, and scripts that reproduce results:

    • Use “align first, list assumptions” to solve guessing;
    • Use a “single verification entry point” to solve not testing;
    • Use “evidence-based reporting” to solve blind trust.

    The cost of getting started is low: begin with the single most painful scenario, get one skill working end to end, then gradually expand it into a system. When “run verification right after writing, and every conclusion comes with evidence” becomes the default behavior, AI coding truly moves from “looks like it runs” to “reliable and deliverable.”