慣性聚合 高效追讀感興趣之博客、新聞、科技資訊
閱原文 以慣性聚合開啟

推薦訂閱源

小众软件
小众软件
博客园 - 叶小钗
有赞技术团队
有赞技术团队
大猫的无限游戏
大猫的无限游戏
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
L
LangChain Blog
Hugging Face - Blog
Hugging Face - Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
T
Tailwind CSS Blog
Jina AI
Jina AI
量子位
Stack Overflow Blog
Stack Overflow Blog
人人都是产品经理
人人都是产品经理
J
Java Code Geeks
V
Visual Studio Blog
月光博客
月光博客

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python)
如何如资深开发者般提示AI编程工具(2026)
Carlos Oliva · 2026-05-28 · via DEV Community

二士共用一AI之器。一者三十秒得可用之码,一者得破烂不堪,费时一辰方补之。

其异非在器,而在令也。

何以多数AI所生之码皆不善?

AI 编码之器,实为模式匹配之器,其涵容之广,无与伦比。授之明则,则能妙续;授之歧义,则妄生臆断——此臆断多谬误。

常见之失:

  • 辞涉空泛:"于吾之应用,增认证之能"——AI 不识汝之架构,不知汝之数据库之式,亦不晓汝之惯例
  • 过巨:"为吾筑一SaaS仪表盘" — 人工智能自创架构,非所求,吾费时一晌解之
  • 无上下文:"解此bug"而无周遭代码 — 人工智能臆测系统
  • 求决于人工智能:以人工智能定产品或架构之择,而非行吾既定之策

其修非异之智器也,乃异之书辞之法也。

框架:境遇→约束→使命

凡有效之编程提示,皆有三部分:

[CONTEXT] Given this [file/system/function],
[CONSTRAINT] following these [conventions/rules],
[TASK] do [specific, scoped thing].

入全景模式 出全屏模式

恶提示:

增删钮

善启:

"在"src/components/ProjectCard.tsx,增一删除之钮,以召之。deleteProject服务器之动作自src/actions/projects.ts点击时,以现有方式显示确认对话框。AlertDialog自shadcn/ui。既删,乃呼revalidatePath('/dashboard')循既有之错谬处理之式:捕其错谬,示以 Toast,勿抛掷。

同请。次者费时四十秒以成文。其出为成品,非仅初稿,需时一辰以洁之。

编码之六式

一、施为之式

为增新制。此最习见,亦易谬误。

范式:

Add [feature] to [file/component].
It should [behavior description].
Use [specific library/pattern] — not [what to avoid].
Follow the existing pattern in [example file or function].
The return/export should look like: [description].

入全景模式 退出全屏模式

示例:

Add pagination to `getUserProjects` in `src/lib/queries.ts`.
It should accept `{ page: number, limit: number }` and return
`{ data, total, hasMore }`.
Use Drizzle's `.offset()` and `.limit()` — not cursor-based pagination.
Follow the same select pattern as `getUserById`: select specific
columns, never `select *`.
Type the return with a `PaginatedResult<T>` generic.

进入全屏模式 退出全屏模式

2. 错误提示

为调试之用。谬误在于未提供足够之背景,以示预期行为与实际行为之差异。

模板:

[function/component] in [file] is broken.
Expected: [what should happen]
Actual: [what is happening]
Error: [exact error message if any]
Relevant context: [the failing code + what it calls]

进入全屏模式 退出全屏模式

示例:

The `createProject` Server Action in `src/actions/projects.ts`
returns { error: "Unauthorized" } even when the user is logged in.

Expected: creates the project and returns { data: project }.
Actual: always hits the requireAuth() error branch.
Error: no error message, just the unauthorized return.

requireAuth() is in `src/lib/auth.ts` — pasting it below.
The user is definitely authenticated (visible in Clerk dashboard).

入全屏模式 出全屏模式

三、重铸提示

以善旧码而不破之。其要者:明示不可易者.

范本:

Refactor [function/file] to [improvement goal].
Keep: [API, behavior, types that must stay identical]
Change: [what should change]
Don't: [specific things to avoid]

入全屏模式 出全屏模式

例:

Refactor `UserTable.tsx` to extract the row actions into a
separate `UserTableActions` component.

Keep: the exact same props API on UserTable, same visual output,
same TypeScript types.
Change: move the action buttons and their handlers to
`UserTableActions.tsx`.
Don't: change how the parent passes data, don't add new dependencies.

入全屏模式 出全屏模式

四、试作之题旨

以生试作。须明言所依之庠序,所覆之域,所拟之象.

范本:

Write [unit/integration] tests for [function/component] in [file].
Testing library: [Vitest/Playwright/etc.]
Cover: [list of specific scenarios]
Mock: [external dependencies to mock and why]
Don't test: [implementation details to avoid]

入全屏模式 出全屏模式

例证:

Write Vitest unit tests for the `createProject` Server Action
in `src/actions/projects.ts`.

Cover:
- success case (user authorized, valid input)
- validation failure (name exceeds 50 chars)
- unauthorized user (requireAuth throws)
- database error (insert fails)

Mock: `src/lib/db.ts` (mock insert to return a fake project),
`src/lib/auth.ts` (mock requireAuth).
Don't test the actual database or actual auth — only the action's logic.

入全屏模式 退出全屏模式

5. 解释提示

为解不识之码。谬者:求泛解也.

非:

"解此码"

善:

"解此Drizzle查询所为。其详:.$onConflictDoUpdate何为,及其故何在"target: [users.clerkId]乎?试以一言总括其于数据库之效。"

所问精,所答亦精。'解此码'之问,得滔滔之文,尽述已知之事。"

6. 迁移与升级之提示

为更新代码至新API版本。"

模板:

Migrate [file] from [old API] to [new API].
Breaking changes to handle: [list specific breaking changes]
Don't change: [function signatures your app uses]
Reference: [paste the relevant migration docs]

入全屏模式 出全屏模式

例:

Migrate `src/lib/auth.ts` from Clerk v4 to Clerk v5.
Breaking changes: `auth()` is now async, `clerkMiddleware` replaces
`withClerkMiddleware`, user object shape changed.
Don't change the signatures my app uses: requireAuth() and getAuthUser().

Here are the relevant Clerk v5 migration notes:
[paste the breaking changes section from the docs]

全屏模式 退出全屏模式

语境为乘数

输出之质,首重语境。AI之器,唯用所授耳.

所当恒备者

  • 确指文件之径
  • 特指函数或组件之名——非全文件
  • 既存之例,所循之式
  • 所用之库名,勿臆其栈
  • 所谓“竟”者何(返回之型,目见之效,行止之状)

所当屏弃者

  • 全篇之码(“此乃吾之全案”)
  • 无关之牍(“此乃/lib中所有”)
  • 跨越诸系统之要求

至要之境,乃足使意旨无歧也

诀(克劳德码)以克劳德码,毋须将码植于提示。但引文件径——"于src/actions/projects.ts"已足,克劳德码自能识之。留植码于特欲彰之片段耳

CLAUDE.md:永续之境,自在无拘

为文之佳,弊在屡复其常:每言“以 cuid2 为标识,用 Server Actions 而非 API routes,返 { data }{ error }……”

Claude 之码,一撰于根之 CLAUDE.md 文:

# CLAUDE.md

## Stack
- Next.js 15 App Router, TypeScript strict mode
- Drizzle ORM + Neon (PostgreSQL)
- Clerk auth, Zod validation, shadcn/ui
- Biome for linting and formatting

## Conventions
- cuid2 for all IDs, never auto-increment integers
- Soft-delete users (deletedAt), never hard delete
- Server Actions for mutations, not API routes
- Import env from `@/lib/env`, never `process.env` directly
- `requireAuth()` at the top of every protected action
- Return `{ data }` or `{ error: string }`, never throw from actions
- Error messages lowercase, no periods

## File structure
- Server Actions: `src/actions/[feature].ts`
- DB queries: `src/lib/queries.ts`
- Shared types: `src/types/[domain].ts`

入全景模式 出全景模式

启程之际,Claude Code读此,自当依此规,于每问皆施之。毋须复言“用cuid2”,自当为之.

分解之务:真为高士之技

别离硕果之徒与困顿之辈者,唯此一技:析务至当其宜.

勿:

"为我构建用户认证系统,含注册、登录、社交认证、Google OAuth、密码重置、邮箱验证、会话管理及账户设置页面。"

需做:

  1. "于Next.js 15 App Router中配置Clerk" → 已完成
  2. "于requireAuth()中创建src/lib/auth.ts助手" → 已完成
  3. "于/dashboard中添加Clerk中间件以保护路由" → 已完成
  4. "于(dashboard)/settings/page.tsx设账户设置之页" → 既成

每步皆三十秒之提示,其果可验。合之与巨请无异——然无虚妄之架构,且汝悉知每句.

其律:若提示令人力尽其详需逾五分钟,则分为二提示。

汝当勿问人工智能者何事

架构之决断:

"当用微服务抑或单体架构耶?"

人工智能将依泛常之模则,予汝似是而非之答。彼不知尔辈之众寡,不知尔辈之流讯,不知尔辈之基业。先自决之,而后询人工智能以行尔之决。

商贾之理:

"用户中止其订阅时,当如何?"

此乃产品之决断,关乎利弊。汝自定之,而后施行之.

安全审计:

"此代码安乎?"

AI可应汝之请而撰安代码,然不能自发性察尽既有代码之瑕疵。当用专器以行审计。

凡不读者:

若欲抄AI之文而不读,止之。汝所运之码,非所解也。其坏也——必坏——汝将不知所求。

前后之例,真如所睹

功能之施

前(三十秒可书,四十五分钟可正):

"于项目列增索"

既(九十秒以成文,一用即效):

"于src/app/(dashboard)/projects/page.tsx增索,当以URL索引之参(?q=),使索状恒存于新启。滤getUserProjects之果,其name含询(不辨大小),用迟索之输入——以useDebouncesrc/hooks/useDebounce.ts迟三百毫秒。勿增新之倚。"


修 bug

旧状:

"吾之表单不提交"

新状:

"于CreateProjectForm中,src/components/CreateProjectForm.tsx不唤 Server Action。React Hook Form 之handleSubmit已接,然 Action (createProject所来)未应。"src/actions/projects.ts 之火不燃——于行动之巅以 console.log 确认。无浏览器之误。二文件并贴于下。"


重构

前:

"清理此文件"

后:

"此 src/lib/db.ts 文件有三内联辅助函数 (withRetrypaginatesoftDelete者,今已用於六處以上。其自src/lib/db-helpers.ts中提取之,並更新所有引用。勿改其函數之簽名或行為,唯改其位耳。"

元技能

欲善於提問,其法在於察知不佳之結果,而問其故.

  • 輸出過於模糊 → 君之任務未足明確
  • 人工智能创构之务甚巨,遂析之
  • 人工智能用格失宜,境缺,增相关之文
  • 人工智能定器物之策,尔求策而非行
  • 码文不合尔之栈,尔之约未备CLAUDE.md

每恶之出,皆示于题之反。宜正题,非独正其出。


得AI之助者,非择异级异模也。乃多费六十秒,以撰更善之问。此乃全胜之机,且日积月累,益彰其效。

详尽指南,附CLAUDE.md模板及Claude Code流程:
https://stacknotice.com/blog/ai-coding-prompts-senior-2026