找回密码
立即注册
搜索
热搜: Java Python Linux Go
发回帖 发新帖

3998

积分

0

好友

524

主题
发表于 5 小时前 | 查看: 3| 回复: 0

原文地址:https://ai.plainenglish.io/how-i-actually-use-claude-code-as-a-senior-engineer-ab58c81c5a0d

原文作者:Aayush Ostwal

1. 根目录 CLAUDE.md

每次你在终端输入 claude 时,它都会在零上下文的状态下启动。关于这一点,现在大概已经有上百万篇文章在重复同样的内容了。

但如果你已经看过上百次类似内容,那么这里才是大多数人会忽略的部分:添加正确的上下文。

有一点我非常坚持,那就是保持简洁。Claude 已经基于海量数据进行了训练。如果你把它本来就知道的内容塞进上下文里,那只是在浪费 token。

下面是我添加到根目录 claude.md 文件中的内容:

# Global Context & Instructions
## My Role
I am a Senior AI Engineer and Full Stack Software Engineer specializing in Large Language Models (LLMs), Retrieval-Augmented Generation (RAG) frameworks, and AI agent orchestration. My daily work bridges high-performance backend engineering and advanced AI research. 
---
## Preferences
When assisting me, please adhere to the following interaction and coding preferences:
**CONVERSATIONAL CHATBOT**
- When I am interacting with claude, make sure the response is very crisp. Always support markdown, table. Limit the output tokens are limited as possible, unless ask to elaborate more.
**PLANNING**
- Always use internet to verify things if you are working on tools like AWS, Bazel, Cloud Architecture.
**CODING PREFERENCES**
- Default to `Python 3.12`. Always use standard coding practices, design pattern, class based approach
- Add crisp and relevant comments in the code, do not add noise.
**CONTENT GENERATION** 
- When helping with Medium articles or YouTube content, provide SEO-optimized descriptions, engaging thumbnails/hooks, and highly structured outlines. Maintain a highly technical but accessible tone for Medium drafts.
**DEBUGGING**
- While debugging cloud related issue, always read latest aws documentation and use aws mcp to fetch details from cloud.
**SKILL USAGE**
- Wherever possible use skills
- Never use skills from `Atlassian`

首先,是的,我添加了一些重复的内容。
但后来我对这个文件进行了优化,用来存储我的个人编码偏好——包括我希望 Claude 使用的工具、MCP 和工作流。
这里的目标是针对我的编码方式进行优化,而不是创建一个完美组织化、适用于整个公司的标准。

2. 像专业人士一样研究和学习

以前,当我想研究或学习新东西时,方法非常直接——阅读 2~3 篇文章,然后亲自动手实践。
现在,你可以高效地阅读 50 多篇文章,并将它们浓缩成一份结构清晰的文档。

下面是我的工作流:
首先,我会打开 Gemini,使用 Deep Research 模式生成一个研究画布。然后将其导出到 Google Doc。
例如,我最近想学习 LLM 评估技术。Gemini 为我生成了一份 18 页的文档:  

LLM评估工具对比表格

它确实让一些内容变得稍微复杂了一点,并且偶尔加入了一些无关细节。但总体来说,我认为自己对想学习的主题已经有了相当扎实的理解。
随着时间推移,我开始尝试另一件事:将完全相同的提示词交给不同模型。  

DeepSeek
Claude
Gemini
ChatGPT
Grok  

你会发现,每个模型给出的结果都明显不同。有些解释得更好,有些挖得更深,还有些在特定主题上更容易理解。
当我尝试学习新知识时,这些就是我经常使用的免费(或基本免费)替代方案。

3. MCP Servers

我不知道为什么人们总是在说 MCP 已经死了。对我来说,它们绝对没有。
我是开发者。任何一天里,我都在写代码、管理 AWS 基础设施、维护 JIRA 工单、回复 Slack 消息,以及处理开发者通常要面对的各种事务。
所以,如果我想把所有这些东西连接到一个统一生态系统中,为什么不用 MCP 呢?
上下文切换的成本会大幅降低。与其在十几个标签页和工具之间来回切换,我可以执行一条命令,在一个地方同时操作多个系统。

最近,我在 AWS 中排查一个问题,于是接入了 AWS MCP。它确实让整个过程顺畅了很多。
它能够读取日志、获取所需 ARN,而当我传入一个 ARN 时,它已经知道我指的是哪个资源以及该资源的配置情况。这种上下文感知能力在调试过程中消除了大量摩擦。
最近,在搭建一个新的 AWS CDK Stack 时,我需要多个 ARN 和 Endpoint。与其在 AWS Console 的不同页面之间来回跳转,我直接用一行命令获取了所需的一切:

AWS MCP终端调用示例

自己安装一个吧:AWS MCP,强烈推荐。

4. Skills

这实际上是一个非常强大的概念。
像 Opus 这样的重型模型通常更昂贵,因为它们会消耗额外的思考 token。但如果你想要的响应能够通过一条可预测的思维链获得——而这条思维链又是你可以预先定义的,那么响应就会变得更快、更便宜,而且一致性更高。
这正是 Skills 发挥作用的地方。

你也不一定需要从零开始编写 Skill。GitHub 上已经有很多社区构建的 Skill 可供使用。下面是我尝试过的一些例子:  

senior-pm-prompt
emilkowalski/skill
aayushostwal/nexus
superpowers  

你可以在根目录 claude.md 文件中定义哪些 Skill 应始终加载,以及 Claude 应遵循哪些行为规范。
有一点需要特别注意:从上下文角度来看,Skill 并不是免费的。默认情况下,Claude 只会为它们预留上下文窗口中的一小部分空间。因此你不能无限制地添加 Skill——能力与可用上下文之间存在权衡。

5. Agent 持久化记忆与 Git Worktree

由于我在创业公司工作,因此同时在同一个仓库中处理多个任务是很常见的情况。
这会带来一个令人烦躁的问题:切换任务时,你要么一直保持终端会话存活,要么回来处理旧任务时重新构建整个上下文。
这很令人沮丧——而且从 token 成本角度来看也很昂贵。

为了管理 Agent 的持久化记忆,我最终采用了两种方案。
第一种是 /save-context 命令,它会将当前上下文写入磁盘文件。这样,当我启动新的会话时,就可以直接重新加载,而无需重新收集所有内容。

# Dump the current session context to a file so it can be resumed later.
Please create a context snapshot file that will let me resume this session from scratch.
## Steps
1. Determine a filename: `context-snapshot-<YYYY-MM-DD-HHMM>.md` using the current date and time.
2. Write the file to the project root (or current working directory if no project root is found). The file should contain the following sections:
---
### Section 1 - Session Goal
A 2–3 sentence summary of the overall goal or task we have been working on in this session.
### Section 2 - Current Status
What has been completed so far and what the current state is. Be specific: mention files created/modified, decisions made, and what was the last action taken.
### Section 3 - Pending Tasks
A prioritised numbered list of things still left to do to complete the goal.
### Section 4 - Key Decisions & Context
Any important decisions, constraints, or background context that the next Claude session must know to continue correctly. Include things like: chosen libraries, architectural decisions, naming conventions, credentials locations, environment details, or anything non-obvious.
### Section 5 - Exact Resume Prompt
Write a ready-to-paste prompt (inside a markdown code block) that the user can drop at the start of a fresh Claude Code session to resume seamlessly. It should:
- Reference the snapshot file by name
- Ask Claude to read the file first
- State the immediate next step clearly
---
3. After writing the file, print the absolute path to the file and a one-line confirmation message.

最近,我开始使用 agentmemory——一个专门用于跨会话维护上下文的仓库。
与其依赖临时终端历史记录,或者每次都重新构建上下文,我把重要信息统一存放在一个地方,让 Agent 从那里继续接手工作。

6. 在多个 GitHub 仓库之间工作

如果你同时维护多个 GitHub 仓库,你一定知道每个仓库都有自己的特点。
不同的编码模式,不同的部署流程,不同的工具链,有时甚至是不同的工程理念。
这正是为什么你不应该用同一种方式对待所有仓库。
你可以为每个项目定义仓库级规则、Skill 和 MCP Server。这并不是什么突破性的想法——很可能你以前已经读到过。
但真正的问题是:你真的已经实现了吗?
实际上,大多数人并没有。

如果你在使用 Monorepo,这会变得更加有价值。你可以为不同服务或模块添加项目级别的 claude.md 文件,让 Claude 更快获得正确的上下文。
与其每次都重新解释架构、约定或依赖关系,不如直接引用对应项目的上下文,例如:

# payments-service/claude.md
- This service handles payment orchestration and Stripe webhooks. 
- Prefer using Nexus for codebase navigation and AWS MCP for infra/log debugging. 
- Follow existing async patterns, avoid introducing sync calls, and reuse shared payment utilities before adding new abstractions.
# frontend/claude.md
- This is a Next.js frontend app. Always follow the existing component structure and design system. 
- Use shared UI components first, prefer server components where possible, and avoid adding new dependencies unless necessary.

归根结底,我并不认为 Agentic AI 的目标是取代工程师。
它的目标是减少摩擦。
更少的上下文切换。更少的重复解释。更少地手动翻查仪表盘、日志、文档和代码库。
大多数人仍然把这些工具当成更聪明的聊天机器人使用。但真正的突破点在于开始围绕它们构建系统——持久化记忆、MCP、仓库专属上下文、Skill,以及符合你实际工作方式的工作流。  

这一切目前都还不完美。很多时候,我仍然在不断尝试。
但有一点已经很明确:学会如何编排这些工具的开发者,前进速度会远远快于那些仅仅把 AI 当作自动补全工具的人。

——由云栈社区编译分享




上一篇:Codex vs Claude Code:哪个AI编程助手更适合你?2026年深度对比解析
下一篇:程序员第14年失业首日:人生这场系统,也该强制重启了
您需要登录后才可以回帖 登录 | 立即注册

手机版|小黑屋|网站地图|云栈社区 ( 苏ICP备2022046150号-2 )

GMT+8, 2026-7-6 09:20 , Processed in 1.200451 second(s), 41 queries , Gzip On.

Powered by Discuz! X3.5

© 2025-2026 云栈社区.

快速回复 返回顶部 返回列表