Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/sync-listings-bot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Listings Sync Bot

# main への push 後に同期ブロックを再生成し、差分があれば
# github-actions[bot] が main に直接 commit する。PR 段階のチェック
# (sync-listings-check.yml) を通過していれば通常は no-op で終わる。
#
# ループ防止: bot 自身の push では走らせない。

on:
push:
branches: [main]

permissions:
contents: write

concurrency:
group: listings-sync-main
cancel-in-progress: false

jobs:
sync:
if: github.actor != 'github-actions[bot]'
name: Auto-commit listing sync
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Run sync_listings --write
run: python3 scripts/sync_listings.py --write

- name: Commit if changed
run: |
if [[ -z "$(git status --porcelain)" ]]; then
echo "No changes — listings already in sync."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add sitemap.xml llms.txt index.html README.md
git commit -m "chore(listings): auto-sync $(date +%F)"
git push
30 changes: 30 additions & 0 deletions .github/workflows/sync-listings-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Listings Sync Check

# PR 用の verify-only。NN-slug/index.html の追加・変更があった際に
# sitemap.xml / llms.txt / index.html / README.md の自動生成ブロックが
# 同期されていなければ fail させる。
# ローカルでの修正コマンド: python3 scripts/sync_listings.py --write
#
# 詳細: scripts/README.md

on:
pull_request:

permissions:
contents: read

jobs:
check:
name: Verify auto-generated listing blocks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Run sync_listings --check
run: python3 scripts/sync_listings.py --check
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
6 changes: 6 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@
- AI 周辺は移り変わりが激しい。古くなったら直す、ではなく、**最初から "更新される前提" で設計**
- HTML × Git × PR ベースの運用は、その変化への対応手段

### 5. 講義一覧は自動同期する(手で更新しない)
- 新しい講義 `NN-slug/index.html` を追加するだけで、`sitemap.xml` / `llms.txt` / ルート `index.html` / `README.md` の講義一覧ブロックが自動同期される
- 真実源は各 `NN-slug/index.html` の `<title>` と `<meta name="description">`
- 同期スクリプト: `python3 scripts/sync_listings.py --write`(PR では `--check` が CI 強制)
- 詳細: [`scripts/README.md`](./scripts/README.md)

---

## 期待する効果(長期)
Expand Down
21 changes: 20 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,26 @@ commit に `Co-Authored-By: Name <email>` trailer を付けると、GitHub の C
### CI

- **Prompt Injection Guard** が HTML/CSS/JS の追加行を自動スキャン
- 失敗時は job summary に検出箇所が表示される
- **Listings Sync Check** が `sitemap.xml` / `llms.txt` / `index.html` / `README.md` の講義一覧ブロックを検証
- 失敗時は job summary に検出箇所・修正コマンドが表示される

### 新しい Lecture を追加するとき

`sitemap.xml` / `llms.txt` / `index.html`(ルート)/ `README.md` の講義一覧は **自動同期** されます。`NN-slug/index.html` の `<title>` と `<meta name="description">` から自動生成されるので、これらのファイルを手で編集する必要はありません。

```bash
# 講義ディレクトリを作って書く
cp -r _template NN-slug
# ... NN-slug/index.html を編集 ...

# 4 つの listing ファイルを同期
python3 scripts/sync_listings.py --write

# 確認用
python3 scripts/sync_listings.py --check
```

PR で同期し忘れた場合は CI(`sync-listings-check.yml`)が落とします。詳細は [`scripts/README.md`](./scripts/README.md)。

### 大きな変更の場合

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,13 @@ AI コーディング(Claude Code 等)を中心に、散在しがちな情

| 章 | 内容 | スライド |
|---|---|---|
| [`00-about/`](./00-about/index.html) | この資料の歩き方(Read me) | 10 枚 |
| [`01-claude-code-intro/`](./01-claude-code-intro/index.html) | Claude Code 入門 | 13 枚 |
<!-- Auto-generated by scripts/sync_listings.py. Do not edit by hand. -->
<!-- listings:auto:lectures-table:start -->
| [`00-about/`](./00-about/index.html) | Read me | 10 枚 |
| [`01-claude-code-intro/`](./01-claude-code-intro/index.html) | なぜ今、Claude Code を学ぶのか | 13 枚 |
| [`02-setup/`](./02-setup/index.html) | Claude Code 環境構築 | 13 枚 |
| [`03-claude-md/`](./03-claude-md/index.html) | CLAUDE.md でプロジェクトを記憶させる | 13 枚 |
<!-- listings:auto:lectures-table:end -->

各章は単体の HTML として完結しているので、ブラウザで開けばそのまま読めます。

Expand All @@ -39,8 +44,13 @@ AI コーディング(Claude Code 等)を中心に、散在しがちな情
### 方法 1: 公開サイト(GitHub Pages)

```
<!-- Auto-generated by scripts/sync_listings.py. Do not edit by hand. -->
<!-- listings:auto:lectures-urls:start -->
https://co-lect.github.io/lectures/00-about/
https://co-lect.github.io/lectures/01-claude-code-intro/
https://co-lect.github.io/lectures/02-setup/
https://co-lect.github.io/lectures/03-claude-md/
<!-- listings:auto:lectures-urls:end -->
```

### 方法 2: クローンしてローカルで開く
Expand Down
3 changes: 3 additions & 0 deletions _template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
<html lang="ja">
<head>
<meta charset="UTF-8">
<!-- 注意: <title> と <meta name="description"> はルートの sitemap.xml / llms.txt /
index.html / README.md の講義一覧に自動転記されます(scripts/sync_listings.py)。
listing にそのまま載る前提で、短く・的確に書いてください。 -->
<title>{{ 講義タイトル }} — Lectures</title>
<meta name="description" content="{{ 1〜2 文の概要。検索・GEO 用。160 字以内で、この回が扱う機能と読者の得るものを書く }}">
<meta name="author" content="@watanabe-kohei-jp">
Expand Down
15 changes: 13 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,25 @@ <h1>Lectures</h1>

<h2>講義</h2>
<ul class="map">
<!-- Auto-generated by scripts/sync_listings.py. Do not edit by hand. -->
<!-- listings:auto:start -->
<li>
<a class="title" href="00-about/">00 — Read me</a>
<div class="desc">教材シリーズの設計思想と歩き方。1 年で陳腐化する世界で、資料をどう作るか(9 枚)</div>
<div class="desc">Lectures シリーズの歩き方 — 1 年で陳腐化する世界で、AI と共同編集する資料はどう作るべきか。教材全体の設計思想を 10 枚で示す Read me。</div>
</li>
<li>
<a class="title" href="01-claude-code-intro/">01 — なぜ今、Claude Code を学ぶのか</a>
<div class="desc">AI コーディングの全体像、ツールの正体、人の立ち位置の変化(12 枚)</div>
<div class="desc">なぜ今 Claude Code を学ぶのか — AI コーディングの全体像、ツールの正体、人の立ち位置の変化を 13 枚で概観する HTML スライド教材。</div>
</li>
<li>
<a class="title" href="02-setup/">02 — Claude Code 環境構築</a>
<div class="desc">Claude Code を動かすまでの手順を 13 枚で解説。プランの選択からインストール・認証・初起動まで。</div>
</li>
<li>
<a class="title" href="03-claude-md/">03 — CLAUDE.md でプロジェクトを記憶させる</a>
<div class="desc">毎回の説明をゼロにする CLAUDE.md の使い方。書き方・置き場所・効果的な3パターンを13枚で解説。</div>
</li>
<!-- listings:auto:end -->
</ul>

<h2>鮮度について</h2>
Expand Down
9 changes: 7 additions & 2 deletions llms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@

## 講義

- [00 Read me](https://co-lect.github.io/lectures/00-about/): 教材シリーズの設計思想と歩き方。1 年で陳腐化する世界で資料をどう作るか(10 枚)
- [01 なぜ今、Claude Code を学ぶのか](https://co-lect.github.io/lectures/01-claude-code-intro/): AI コーディングの全体像、ツールの正体、人の立ち位置の変化(13 枚)
<!-- Auto-generated by scripts/sync_listings.py. Do not edit by hand. -->
<!-- listings:auto:start -->
- [00 Read me](https://co-lect.github.io/lectures/00-about/): Lectures シリーズの歩き方 — 1 年で陳腐化する世界で、AI と共同編集する資料はどう作るべきか。教材全体の設計思想を 10 枚で示す Read me。
- [01 なぜ今、Claude Code を学ぶのか](https://co-lect.github.io/lectures/01-claude-code-intro/): なぜ今 Claude Code を学ぶのか — AI コーディングの全体像、ツールの正体、人の立ち位置の変化を 13 枚で概観する HTML スライド教材。
- [02 Claude Code 環境構築](https://co-lect.github.io/lectures/02-setup/): Claude Code を動かすまでの手順を 13 枚で解説。プランの選択からインストール・認証・初起動まで。
- [03 CLAUDE.md でプロジェクトを記憶させる](https://co-lect.github.io/lectures/03-claude-md/): 毎回の説明をゼロにする CLAUDE.md の使い方。書き方・置き場所・効果的な3パターンを13枚で解説。
<!-- listings:auto:end -->

## メタ

Expand Down
63 changes: 63 additions & 0 deletions scripts/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# scripts/

リポジトリ運用のためのユーティリティスクリプト。

---

## `sync_listings.py` — 講義一覧の自動同期

`NN-slug/index.html` を真実源(source of truth)として、以下の自動生成ブロックを同期する:

| ファイル | 同期される場所 |
|---|---|
| `sitemap.xml` | `<!-- listings:auto:start --> ... :end -->` — 講義 URL の `<url>` ブロック |
| `llms.txt` | 同上 — 「## 講義」の箇条書き |
| `index.html`(ルート) | 同上 — `<ul class="map">` の中身 |
| `README.md` | `<!-- listings:auto:lectures-table:start -->` 〜 — 章テーブル |
| `README.md` | `<!-- listings:auto:lectures-urls:start -->` 〜 — 公開 URL 一覧 |

各 `NN-slug/index.html` の `<title>` と `<meta name="description">` と `<section>` 数が抽出元。

### 使い方

```bash
# 変更を書き戻す(ローカル開発で使う)
python3 scripts/sync_listings.py --write

# ずれていないか確認(CI 用、exit 1 で fail)
python3 scripts/sync_listings.py --check
```

### 新しい講義を追加する流れ

1. `_template/` をコピーして `NN-slug/` を作る
2. `<title>` / `<meta name="description">` / スライド本文を書く
3. `python3 scripts/sync_listings.py --write` で 4 ファイルを同期
4. `git add -A && git commit && PR`

PR を上げ忘れても CI の `sync-listings-check.yml` が落とすので発見できる。
main にマージ後は念のため `sync-listings-bot.yml` が再生成する二重防衛。

### 依存

- Python 3.8+(標準ライブラリのみ。`pip install` 不要)
- `git`(lastmod の取得に使用)

### マーカー設計

各ファイルに HTML/XML コメント形式でマーカーを埋める。マーカー間の本文のみ
スクリプトが再生成し、マーカー外は触らない。

```
<!-- listings:auto:start -->
... 自動生成 ...
<!-- listings:auto:end -->
```

同じファイルに 2 か所以上ある場合は名前付きにする:

```
<!-- listings:auto:<name>:start -->
... 自動生成 ...
<!-- listings:auto:<name>:end -->
```
Loading
Loading