蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

生成一份可复核的项目指南

PYTHONPython 3.12.14,临时项目。真实模型生成另行复核。seed_guide.py
seed_guide.py33 行
"""Write an initial project guide from the sample project's declared fields."""
import argparse
import json
from pathlib import Path


def create(root):
    config=json.loads((root/"guide-input.json").read_bytes())
    lines=["# "+config["name"],"",
           "## Purpose",config["purpose"],"",
           "## Runtime",config["runtime"],"",
           "## Layout",f"- Entry: {config['entry']}", f"- Tests: {config['test']}", "",
           "## Verify",f"Run: python {config['test']}",config["expectation"],""]
    for name in ("entry","test"):
        item=(root/config[name]).resolve(strict=True)
        if not item.is_relative_to(root) or not item.is_file():
            raise ValueError("project file is invalid")
    output=root/"CLAUDE.md"
    with output.open("x",encoding="utf-8",newline="\n") as handle:
        handle.write("\n".join(lines))
    return output


if __name__=="__main__":
    p=argparse.ArgumentParser()
    p.add_argument("workspace",type=Path)
    args=p.parse_args()
    try:
        result=create(args.workspace.resolve(strict=True))
    except FileExistsError:
        p.exit(3,"CLAUDE.md already exists\n")
    print(result.name)
本例需在 Python 3.12.14,临时项目。真实模型生成另行复核。 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程

运行环境:Python 3.12.14,临时项目。真实模型生成另行复核。

入口文件:projects/claude-code-ide-and-guide/seed_guide.py

本地运行步骤快速上手
  1. 点击上方“保存源码”保存为 seed_guide.py,或下载右侧课程工程包。
  2. 确认本地已准备 Python 3.12.14,临时项目。真实模型生成另行复核。。
  3. 按对应章节命令执行,结合正文核对实际输出。
附件与关联工程包下载

下载课程关联工程包:Claude Code

课程关联工程包(登记关联42章) · 含当前章节或实例 · mbskycom202612a3117.zip

下载课程关联工程包:Claude Code

课程关联工程包(登记关联2章) · 含当前章节或实例 · mbskycom202612a3130.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习