跳到正文
Skillpedia
通用编程29k · #9611

strict-api

它能做什么

这项技能让 AI 检查它使用的每个函数、导入和方法在你运行的版本中是否真实存在。适合希望代码第一次就能运行的开发者。

适用场景

  • ✓当你表示不希望 AI 编造函数或 API 的时候。
  • ✓当代码依赖的库版本尚未经过核实时。
  • ✓当某个框架的名称很相似、你想避免混淆时。

技能链接

https://github.com/alirezarezvani/claude-skills/blob/main/engineering/strict-api/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/alirezarezvani/claude-skills/blob/main/engineering/strict-api/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“请编写这段 Express 代码,并确保你使用的每个方法在我们的版本中真实存在。”

每周 5 个新技能,1 分钟读完。

工作原理

在编写代码之前,它会列出代码将使用的每个 API,并确认其存在于已安装的版本中,对无法确认的内容则不予使用。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Strict API Verification

Inventing a function that doesn't exist is the opposite of efficiency. You wrote a line that looks minimal. You shipped a bug that takes an hour to debug. The true minimal path is: use only what is provably there.

Overview

This skill is a reality-check layer applied before any code is written. It is not about being slow — it is about being correct the first time. Use it alongside minimalist when the user wants both less code and verified code.

The Only Rule

Before you write any function call, import, or method access, you must be able to answer:

"Does this exist in the version the user is running?"

If the answer is "probably" or "I think so" — stop. You don't know. Say so.

What This Blocks

Made-up methods:

  • fs.readFileLines() does not exist in Node.js.
  • path.combine() is .NET, not Node.js.
  • csv.read_csv() is pandas, not Python's csv module.

Writing these is not minimal code — it is confident garbage.

Framework confusion. Every framework has a twin that sounds like it:

  • render_template (Flask) vs render() (Django)
  • useForm() (react-hook-form) vs nothing built into React
  • app.listen() (Express) vs server.listen() (raw Node.js http)

Deprecated APIs. Writing a deprecated method is writing code that will break on the next upgrade.

Workflow

  1. Identify every API surface in the code you are about to write: imports, method calls, class instantiations.
  2. Verify each one against the user's stated version. If no version is stated, ask once.
  3. Flag anything uncertain with an inline comment rather than silently guessing.
  4. Prefer verbose-but-correct over terse-but-wrong.

When you are not sure if a method exists, annotate it inline:

// verify fs.openAsBlob exists in your Node.js version (>= 20.0)
const blob = await fs.openAsBlob(path);

One comment costs nothing. A silent wrong call costs an hour of the user's time.

If the uncertainty is too high to write correct code without guessing, say:

"I'd need to check whether X exists in version Y before using it. What version are you on?"

Anti-Patterns

Anti-Pattern What to do instead
Writing a method call you vaguely remember Stop and verify the exact signature
Silently using a deprecated API Use the current API and note the deprecation
Assuming API parity across frameworks Explicitly name the framework and version
Guessing import paths Check the package's actual export structure
Using an API from a different language's stdlib Verify it exists in this language
Writing "it should work" without checking Ask what version the user is on

Cross-References

  • Related: engineering/minimalist — use together: minimalist reduces code volume; strict-api ensures what is written is correct.
  • Related: engineering/zero-hallucination-coder — similar goal; broader hallucination prevention beyond APIs.
  • Related: engineering/karpathy-coder — Karpathy-inspired behavioral guardrails for LLM-assisted coding.
常见问题

这会让编写代码变慢吗?

会增加一个检查步骤,但它的目的是避免日后需要更长时间修复的错误。

它能阻止哪类错误?

它会阻止虚构的方法、混淆的框架名称以及已弃用的调用。

它能和代码量少的技能一起使用吗?

可以。该技能可以与要求较少代码的技能一同使用。

详情

作者的原始描述

Use when the user says 'no hallucinations', 'verify APIs' or 'don't invent functions', or code depends on a library version you have not checked. Requires proof that every method, import and variable exists in the installed version before using it.

repo: alirezarezvani/claude-skills

热度

GitHub 星标
29k
排名
#9611
许可证
MIT
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能