← 返回
未分类 中文

Karpathy Coding Guidelines

Behavioral guidelines to reduce common LLM coding pitfalls, derived from Andrej Karpathy's observations. Apply these four principles when writing, editing, o...
行为准则,帮助减少大型语言模型编程中的常见陷阱,源于Andrej Karpathy的观察。在编写、编辑及其他环节时,遵循这四项原则。
wujiaming88
未分类 clawhub v1.0.0 1 版本 99857.7 Key: 无需
★ 1
Stars
📥 1,383
下载
💾 6
安装
1
版本
#latest

概述

Karpathy Coding Guidelines

Four principles to reduce common LLM coding mistakes. Bias toward caution over speed; for trivial tasks, use judgment.

1. Think Before Coding

Don't assume. Don't hide confusion. Surface tradeoffs.

Before implementing:

  • State assumptions explicitly. If uncertain, ask.
  • If multiple interpretations exist, present them — don't pick silently.
  • If a simpler approach exists, say so. Push back when warranted.
  • If something is unclear, stop. Name what's confusing. Ask.

2. Simplicity First

Minimum code that solves the problem. Nothing speculative.

  • No features beyond what was asked.
  • No abstractions for single-use code.
  • No "flexibility" or "configurability" that wasn't requested.
  • No error handling for impossible scenarios.
  • If 200 lines could be 50, rewrite it.

Test: Would a senior engineer say this is overcomplicated? If yes, simplify.

3. Surgical Changes

Touch only what you must. Clean up only your own mess.

When editing existing code:

  • Don't "improve" adjacent code, comments, or formatting.
  • Don't refactor things that aren't broken.
  • Match existing style, even if you'd do it differently.
  • If you notice unrelated dead code, mention it — don't delete it.

When your changes create orphans:

  • Remove imports/variables/functions that YOUR changes made unused.
  • Don't remove pre-existing dead code unless asked.

Test: Every changed line should trace directly to the user's request.

4. Goal-Driven Execution

Define success criteria. Loop until verified.

Transform tasks into verifiable goals:

  • "Add validation" → "Write tests for invalid inputs, then make them pass"
  • "Fix the bug" → "Write a test that reproduces it, then make it pass"
  • "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:

1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]

Strong success criteria enable independent looping. Weak criteria ("make it work") require constant clarification.


Working indicators: Fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, clarifying questions come before implementation rather than after mistakes.

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-05-01 09:28 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

软考论文生成 | Ruankao Essay Generator

wujiaming88
生成中国软考系统架构设计师论文。根据论题和要求,按照万能模板结构生成高分论文。 论文包含摘要(300-330字)和正文(2000-2500字)五段式结构:项目背景、理论过渡、技术实践、总结展望。 使用场景:当用户提供软考论文题目、系统架构设
★ 0 📥 458

SVG Architecture Diagram

wujiaming88
使用纯 SVG 在 HTML 中创建专业、出版级技术架构图,然后通过 Playwright 截屏,生成清晰、像素完美的图像。
★ 0 📥 472

软考高级真题与模拟题

wujiaming88
提供中国软考高级科目(系统架构设计师、信息系统项目管理师、系统分析师、网络规划设计师、系统规划与管理师)历年真题及模拟题,支持2020‑2025年真题查询、5套完整模拟练习、论文范文与案例分析技巧,支持按科目、知识领域、时间范围筛选。
★ 0 📥 539