[cc] Claude Code Practice

工作流介绍


Ref: 36 ClaudeCode进阶使用 工作流介绍

Step 1: 项目初始化
    ↓ 描述项目目标 → AI 生成项目骨架

Step 2: 建立 CLAUDE.md(项目上下文)
    ↓ 可运行 /init 让 AI 自动生成

Step 3: 配置权限与默认模式
    ↓ .claude/settings.json,复杂项目可默认 plan 模式

Step 4: 功能开发
    ↓ 一次一个功能,逐个 Explore → Plan → Implement

Step 5: 代码审查与测试
    ↓ 用 /review 让 AI 生成测试并跑起来

Step 6: 提交代码
    ↓ git commit 保存进度

 

image

“使用 node.js 构建一个前端页面,显示出 Hello ai coding 几个字”

模型给出 Planning 的预览草稿。

确定后即可让模型开始实现。

 

 

 

最佳实践


1. 需求尽量详尽

2. 有参考最好

3. 显式列出计划

4. 一件一件去做(一件最好不大于5个文件,200行代码)

 

死记硬背如下

image

 

image

 

MCP 集散地: https://www.modelscope.cn/mcp/servers/@amap/amap-maps

 

 

现代编程

CodeGeex 针对某个方法,类这个级别,免费且可用。

Ubuntu Install Claude Code. 在 vscode 里安装插件即可。

若报错:先试最简单的:Cmd/Ctrl+Shift+P 打开命令面板,输入并执行 'Developer: Reload Window'。有时候只是扩展加载时序问题,重载就好了。

 

image

 

 

{
  "permissions": {
    "allow": [
      "Read",          // 允许 Claude Code 读取项目中的文件
      "Write",         // 允许 Claude Code 创建或修改文件
      "Bash(npm *)",   // 允许执行所有 npm 命令,例如 npm install、npm test
      "Bash(git *)",   // 允许执行所有 git 命令,例如 git status、git diff、git commit
      "Bash(node *)"   // 允许执行 node 命令,例如 node app.js
    ],

    "deny": [
      "Bash(rm -rf *)" // 明确禁止执行 rm -rf,防止递归强制删除文件或目录
    ]
  },

  "autoCompactThreshold": 80
  // 当上下文使用量达到设定阈值时,触发自动压缩,
  // 避免长时间对话持续占用 Context Window
}
settings.local.json

 

 

PLAN First.  

Let me know what you need!

我要做一个 Python web 记账工具,功能包括: - 添加账目(金额、分类、日期、备注)——在网页表单里填写 - 查看列表(按月份和分类筛选)——表格展示 - 删除账目——输入 ID 删除 - 分类统计——柱状图 + 统计表 技术栈用 Python + streamlit + sqlite3。 预设 6 个分类:餐饮、交通、购物、娱乐、居住、其他。 我是编程新手,请先出方案再动手。
 

好的,我理解你的需求。作为编程新手,先规划再动手是非常明智的做法。让我给你出一个清晰的方案:

📋 项目方案

1. 项目结构

finance_cli/
├── app.py              # 主应用文件(Streamlit入口)
├── database.py         # 数据库操作模块
├── requirements.txt    # 依赖包
└── finance.db         # SQLite数据库文件(运行时生成)

2. 数据库设计

只需一张表:expenses

字段类型说明
id INTEGER 主键,自增
amount FLOAT 金额
category TEXT 分类
date DATE 日期
note TEXT 备注

 

3. 核心模块划分

模块职责
database.py 初始化数据库、增删查操作
app.py 页面布局、表单交互、数据展示

4. Streamlit 页面结构

    • 侧边栏菜单:页签选择(新增、查看、删除、统计)
    • 新增页面:表单输入
    • 查看页面:筛选器 + 表格展示
    • 删除页面:ID输入框
    • 统计页面:柱状图 + 统计表

5. 技术选择理由

    • Streamlit:新手友好,无需HTML/CSS,快速上手
    • SQLite3:轻量级,无需额外服务器
    • Pandas:表格处理简单
    • Matplotlib/Altair:图表可视化(Streamlit原生支持)

6. 实现步骤

    1. ✅ 安装依赖 & 初始化项目
    2. ✅ 建立数据库模块(创建表、增删查函数)
    3. ✅ 写 Streamlit 主框架(侧边栏 + 页签)
    4. ✅ 实现各页面功能(表单、筛选、图表)
    5. ✅ 测试修改

💡 为什么这个方案适合新手?

    1. 代码简洁:Streamlit 自动处理前端,你只写 Python
    2. 逐步递进:先简单后复杂,数据库 → UI → 统计
    3. 易于调试:每个函数职责清晰,改一个地方不会影响其他

有问题吗? 或者你想:

    • 调整需求(比如增加预算限制、支出趋势图)?
    • 先看具体代码示例?
    • 直接开始实现?

告诉我你的想法!

 

 

得到了结果,效果很炸裂,如下。

image

 

image

 

 

CC Switch

cc-switch 不是 Anthropic 官方工具,是一个第三方开源项目(GitHub: farion1231/cc-switch),用来在 Claude Code / Codex / Gemini CLI 等多个 AI 编码工具之间快速切换 API 供应商配置(比如在官方 Anthropic API 和第三方中转服务之间切换)。

本质上 是帮你自动改写  ~/.claude/settings.json 里的 ANTHROPIC_BASE_URL / ANTHROPIC_AUTH_TOKEN,不用手动改文件。

image

 

 切换到 DeepSeek v4 pro后,继续升级后的效果。

image

image

 

需求越细,单位任务越简单,能使用 更便宜的模型,结果会得到更便宜的成本。

2026 年 4 月 The Information 报道的 Meta 内部 “tokenmaxxing” 事件

 

 

Codex

最好是选择一个已有文件夹,而非新建。 

权限定义如下:

image

 

~/.codex/config.toml

Codex 用户级配置 模型、sandbox、approval、MCP、multi-agent 等。

 

.codex/config.toml

项目级配置。

#:schema https://developers.openai.com/codex/config-schema.json

# Codex project configuration for the Finance Tracker repository.
#
# This file is committed with the project and applies only when Codex trusts
# this repository. User-wide defaults remain in ~/.codex/config.toml.
# Never place API keys, passwords, or other secrets in this file.

# Ask before commands need permissions beyond the configured sandbox.
approval_policy = "on-request"

# Allow edits inside this repository while protecting paths outside it.
sandbox_mode = "workspace-write"

# Optional project overrides -------------------------------------------------
# Uncomment these only if every contributor should use the same defaults.
# Command-line flags and IDE selections can still take precedence.

# model = "gpt-5.6"
# model_reasoning_effort = "medium"

# Network access is disabled by default in the workspace-write sandbox.
# Enable this only if project commands must download packages or call APIs.
#
# [sandbox_workspace_write]
# network_access = true

 

./AGENTS.md

项目级 Instructions。

# Finance Tracker — Codex Instructions

## Project overview

- This repository is a single-page personal expense tracker.
- The stack is Python 3, Streamlit, SQLite, pandas, and Altair.
- The user interface and source comments are primarily Chinese.
- Preserve the existing dark visual theme and accessible interaction patterns.

## Architecture

- `app.py` initializes Streamlit, renders the sidebar and dashboard, and routes tabs.
- `database.py` owns SQLite schema and data-access operations. Keep Streamlit calls out of it.
- `tabs/` contains one UI module per application tab.
- `styles.py` contains shared Streamlit CSS.
- `visual_3d.py` contains the isolated interactive 3D hero component.
- `config.py` is the source of truth for categories, colors, emoji, and database constants.
- `utils.py` contains presentation helpers and calculated dashboard metrics.

## Working conventions

- Keep changes small and preserve existing behavior unless the task requires otherwise.
- Reuse category constants from `config.py`; do not duplicate category definitions.
- Use parameterized SQL and keep all database operations inside `database.py`.
- Keep tab modules focused on rendering and call the database layer for persistence.
- Match the surrounding Chinese copy and comments when changing user-facing UI.
- Do not add a production dependency when the standard library or current stack is sufficient.
- Never commit credentials, local secrets, generated databases, or environment-specific settings.

## Verification

After modifying Python code, run:

```bash
python -m py_compile app.py config.py database.py styles.py utils.py visual_3d.py tabs/*.py
```

For UI changes, also smoke-test the app when the environment permits:

```bash
streamlit run app.py --server.headless true
```

Before finishing, run:

```bash
git diff --check
git status --short
```

Report any check that could not be run. Do not commit changes unless the user asks.

## Data safety

- Treat `finance.db` as user data.
- Do not delete or recreate the database unless explicitly requested.
- Preserve backward compatibility when changing the schema; use a migration when needed.
- Confirm the exact record and intent before performing destructive data operations.

## Code review rules

- Flag SQL assembled from user-provided strings instead of parameters.
- Flag UI changes that bypass `config.py` category definitions.
- Flag database writes performed directly from `app.py` or `tabs/`.
- Flag changes that can erase or silently rewrite existing finance records.
- Flag new animations that ignore `prefers-reduced-motion`.

 

 

最直观的对应关系:

Claude CodeCodex
CLAUDE.md AGENTS.md
~/.claude/settings.json ~/.codex/config.toml
.claude/settings.local.json .codex/config.toml 中相应配置
Claude Skills Codex Skills
Claude MCP config Codex MCP config

 

Codex 能读懂这个 .claude/settings.local.json 文件的内容,并不等于:

Codex 会按照 Claude Code 的 settings schema 来执行它。

 

posted @ 2026-08-08 22:12  郝壹贰叁  阅读(14)  评论(0)    收藏  举报