mirror of
https://github.com/shareAI-lab/analysis_claude_code.git
synced 2026-09-20 12:13:38 +08:00
feat: consolidate course into 21 lessons
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
[English](README.md) · [中文](README.zh.md) · [日本語](README.ja.md)
|
||||
|
||||
s01 → ... → s08 → s09 → `s10` → [s11](../s11_error_recovery/) → s12 → ... → s20 → s21 → s22
|
||||
s01 → ... → s08 → s09 → `s10` → [s11](../s11_error_recovery/) → s12 → ... → s20 → s21
|
||||
> *"モデル入力は組み立てるもの、固定するものではない"* — 安定セクション + 実行時状態 + キャッシュ。
|
||||
>
|
||||
> **Harness レイヤー**: コンテキスト組み立て — 安定した指示と動的状態をモデル入力にまとめる。
|
||||
@@ -119,8 +119,6 @@ def get_system_prompt(context: dict) -> str:
|
||||
|
||||
`hash()` ではなく `json.dumps` を使用:Python 組み込みの `hash()` にはプロセスランダム化があり(安定したキャッシュキーに不適切)、list/dict で `unhashable type` エラーになる。
|
||||
|
||||
注意:このキャッシュは「プロセス内での文字列再組み立ての回避」のみ。CC の API prompt cache とは別物。CC の prompt cache は `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` で静的/動的部分を分離し、静的部分が global cache に命中する。動的内容が変化しても静的部分は無効化されない。
|
||||
|
||||
### context: 実際の状態、キーワード推測ではない
|
||||
|
||||
context は現在の実行時状態の実際の状態を反映:
|
||||
@@ -178,7 +176,7 @@ cd learn-claude-code
|
||||
python s10_system_prompt/code.py
|
||||
```
|
||||
|
||||
安全上の注意:この集中教材はモデルが渡す `bash` 文字列を `shell=True` で実行し、s03 の permission gate を省略している。破棄可能な workspace だけで実行し、本番 harness では permission と sandbox の境界を戻すこと。
|
||||
**安全上の注意**:このスクリプトはモデルが生成した `bash` 文字列を `shell=True` で実行し、s03 の permission gate を含まない。破棄可能な workspace でのみ実行すること。
|
||||
|
||||
観察のポイント:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[English](README.md) · [中文](README.zh.md) · [日本語](README.ja.md)
|
||||
|
||||
s01 → ... → s08 → s09 → `s10` → [s11](../s11_error_recovery/) → s12 → ... → s20 → s21 → s22
|
||||
s01 → ... → s08 → s09 → `s10` → [s11](../s11_error_recovery/) → s12 → ... → s20 → s21
|
||||
> *"Model input is assembled, not hardcoded"* — Stable sections + runtime state + caching.
|
||||
>
|
||||
> **Harness Layer**: Context assembly — turn stable instructions and dynamic state into model input.
|
||||
@@ -119,8 +119,6 @@ def get_system_prompt(context: dict) -> str:
|
||||
|
||||
`json.dumps` instead of `hash()`: Python's built-in `hash()` has process randomization (unsuitable for stable cache keys) and throws `unhashable type` on nested dicts/lists.
|
||||
|
||||
Note: this cache only avoids redundant string assembly within a process. It's not the same as CC's API prompt cache, which uses `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` to separate static and dynamic parts — the static parts hit global cache and don't invalidate when dynamic content changes.
|
||||
|
||||
### context: Real State, Not Keyword Guessing
|
||||
|
||||
Context reflects the actual runtime state:
|
||||
@@ -178,7 +176,7 @@ cd learn-claude-code
|
||||
python s10_system_prompt/code.py
|
||||
```
|
||||
|
||||
Safety note: this focused teaching script still executes the model's `bash` string with `shell=True` and omits s03's permission gate. Run it only in a disposable workspace; production harnesses must restore permission and sandbox boundaries.
|
||||
**Safety note**: The script executes model-generated `bash` strings with `shell=True` and does not include the permission gate from s03. Run it only in a disposable workspace.
|
||||
|
||||
What to watch for:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[English](README.md) · [中文](README.zh.md) · [日本語](README.ja.md)
|
||||
|
||||
s01 → ... → s08 → s09 → `s10` → [s11](../s11_error_recovery/) → s12 → ... → s20 → s21 → s22
|
||||
s01 → ... → s08 → s09 → `s10` → [s11](../s11_error_recovery/) → s12 → ... → s20 → s21
|
||||
> *"模型输入是组装出来的,不是写死的"* — 稳定分段 + 运行时状态 + 缓存。
|
||||
>
|
||||
> **Harness 层**: 上下文组装 — 把稳定指令和动态状态组成模型输入。
|
||||
@@ -119,8 +119,6 @@ def get_system_prompt(context: dict) -> str:
|
||||
|
||||
用 `json.dumps` 而不是 `hash()`:Python 内置 `hash()` 有进程随机化,不适合做稳定 cache key,而且遇到 list/dict 会报 `unhashable type`。
|
||||
|
||||
注意:这里的缓存只是"避免重复拼接字符串",和 CC 的 API prompt cache 不是一回事。CC 的 prompt cache 通过 `SYSTEM_PROMPT_DYNAMIC_BOUNDARY` 分隔静态和动态部分,静态部分命中 global cache,不因动态内容变化而失效。
|
||||
|
||||
### context: 真实状态,不是关键词猜测
|
||||
|
||||
context 反映当前运行态的真实状态:
|
||||
@@ -178,7 +176,7 @@ cd learn-claude-code
|
||||
python s10_system_prompt/code.py
|
||||
```
|
||||
|
||||
安全说明:这份聚焦教学脚本仍用 `shell=True` 执行模型给出的 `bash` 字符串,并省略了 s03 的权限闸门。只在可丢弃工作区运行;生产 harness 必须恢复权限与沙箱边界。
|
||||
**安全说明**:脚本使用 `shell=True` 执行模型生成的 `bash` 字符串,并未接入 s03 的权限闸门。请只在可丢弃的工作区中运行。
|
||||
|
||||
观察重点:
|
||||
|
||||
|
||||
@@ -74,9 +74,7 @@ def get_system_prompt(context: dict) -> str:
|
||||
|
||||
Uses json.dumps for deterministic serialization, not Python's hash()
|
||||
which has process randomization and fails on nested dicts/lists.
|
||||
This cache only avoids redundant string assembly within a process.
|
||||
Real Claude Code additionally protects API-level prompt cache via
|
||||
stable section ordering and SYSTEM_PROMPT_DYNAMIC_BOUNDARY.
|
||||
Stable serialization lets identical context reuse the assembled prompt.
|
||||
"""
|
||||
global _last_context_key, _last_prompt
|
||||
key = json.dumps(context, sort_keys=True, ensure_ascii=False, default=str)
|
||||
|
||||
Reference in New Issue
Block a user