Logo Dev Math Lesson

Dev Math Lesson

Cộng đồng
Nebulavenus
dev-math-lesson

Add a math concept - create lesson, update library, document usage

Tổng quan

Nhà phát hànhNebulavenus
Kho mãforge-gpu
Tên kỹ năngdev-math-lesson
Sao
46
Bản fork
7
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépZlib
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Đầy đủ trong hướng dẫn

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được Nebulavenus công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Dev Math Lesson trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/dev-math-lesson
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Nebulavenus/forge-gpu.git /tmp/forge-gpu
mkdir -p .claude/skills
cp -r /tmp/forge-gpu/.claude/skills/dev-math-lesson .claude/skills/dev-math-lesson
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Dev Math Lesson trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Dev Math Lesson ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Dev Math Lesson không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Create a new math lesson and update the math library (common/math/forge_math.h).

When to use this skill:

  • You need math functionality that doesn't exist in forge_math.h yet
  • A GPU lesson requires new math operations
  • You want to teach a foundational math concept

Smart behavior:

  • Before creating a lesson, check if the math already exists in forge_math.h
  • If it exists, just document it better or create a lesson for existing code
  • If creating from a GPU lesson's needs, extract only the math (not GPU-specific code)

Arguments

The user (or you) can provide:

  • Number: two-digit lesson number (e.g. 01, 02)
  • Concept name: kebab-case (e.g. vectors, matrices, quaternions)
  • Description: what this teaches (e.g. "Vectors, dot product, normalization")

If any are missing, infer from context or ask.

Steps

1. Analyze what's needed

  • Check common/math/forge_math.h: Does this math already exist?
  • Check existing math lessons: Is there already a lesson for this?
  • Identify the scope: What specific operations/concepts are needed?

2. Create the lesson directory

lessons/math/NN-concept-name/

3. Create a demo program (main.c)

A small, focused C program that demonstrates the math concept visually or numerically.

Requirements:

  • Standalone — Can run without GPU (uses SDL for window/input if visual, or just printf if not)
  • Clear output — Shows the math in action (visualization or printed results)
  • Well-commented — Explains what's happening and why
  • Uses the math library — #include "math/forge_math.h"

Examples:

  • Vectors: print dot products, show perpendicular/parallel cases
  • Matrices: print a rotation matrix, show before/after transformation
  • Visual: use SDL to draw vectors, show transformations in a window

Template structure:

c
/*
 * Math Lesson NN — Concept Name
 *
 * Demonstrates: [what this shows]
 *
 * SPDX-License-Identifier: Zlib
 */

#include <SDL3/SDL.h>
#include "math/forge_math.h"

int main(int argc, char *argv[])
{
    (void)argc;
    (void)argv;

    if (!SDL_Init(SDL_INIT_VIDEO)) {
        SDL_Log("SDL_Init failed: %s", SDL_GetError());
        return 1;
    }

    /* Demonstrate the math concept here */

    SDL_Quit();
    return 0;
}

Console output formatting:

  • Use ASCII-only characters for console output (cross-platform compatibility)
  • Avoid Unicode box-drawing, symbols, or special characters that may not render on Windows Terminal
  • Good: -, =, *, |, ->, [OK], [!], "degrees", "in", "+/-"
  • Bad: ─, ═, •, ↓, →, ✓, ⚠, °, ∈, ± (may render as garbled text on Windows)

4. Create CMakeLists.txt

cmake
add_executable(NN-concept-name main.c)
target_include_directories(NN-concept-name PRIVATE ${FORGE_COMMON_DIR})
target_link_libraries(NN-concept-name PRIVATE SDL3::SDL3)

add_custom_command(TARGET NN-concept-name POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        $<TARGET_FILE:SDL3::SDL3-shared>
        $<TARGET_FILE_DIR:NN-concept-name>
)

5. Create README.md

Structure:

markdown
# Math Lesson NN — Concept Name

[Brief subtitle explaining what this teaches]

## What you'll learn

[Bullet list of math concepts covered]

## Key concepts

[Bullet list of core takeaways:]
- **Concept 1** — Brief explanation
- **Concept 2** — Brief explanation
- **Formula/operation** — What it does and when to use it

## The Math

[Explain the concept clearly, with intuition before formulas]

### [Subconcept 1]

[Explanation, formula, geometric meaning]

### [Subconcept 2]

[Explanation, formula, geometric meaning]

## Where it's used

Graphics and game programming uses this for:
- [Use case 1]
- [Use case 2]

**In forge-gpu lessons:**
- [Link to GPU lesson] uses `function_name()` for [purpose]
- [Link to GPU lesson] uses `function_name()` for [purpose]

## Building

```bash
cmake -B build
cmake --build build --config Debug

# Windows
build\lessons\math\NN-concept-name\Debug\NN-concept-name.exe

# Linux / macOS
./build/lessons/math/NN-concept-name/NN-concept-name
```

[Brief note on what the demo shows]

## Result

[Brief description of expected demo output or what the program demonstrates]

**Example output:**
```text
[Copy actual program output here]
```

**Important:** Copy output directly from running the program—don't manually type it.

## Exercises

1. [Exercise extending the concept]
2. [Exercise applying it differently]
3. [Exercise combining with other concepts]

## Further reading

- [Relevant math lesson that builds on this]
- [External resource if helpful]

6. Update common/math/forge_math.h

Add the new math functions following the library's conventions:

  • Documentation: Summary, parameters, returns, usage example, geometric intuition
  • Naming: typeN_verb (e.g., vec3_dot, mat4_rotate_x)
  • Implementation: Clear, readable, matches textbook descriptions
  • Inline: Use static inline for header-only functions
  • Comments: Explain the math, not just the code

Example:

c
/* Compute the dot product of two 3D vectors.
 *
 * The dot product measures how much two vectors point in the same direction.
 * Result = |a| * |b| * cos(θ), where θ is the angle between them.
 *
 * If the result is:
 *   - Positive: vectors point somewhat in the same direction
 *   - Zero:     vectors are perpendicular
 *   - Negative: vectors point in opposite directions
 *
 * Usage:
 *   vec3 a = vec3_create(1.0f, 0.0f, 0.0f);
 *   vec3 b = vec3_create(0.0f, 1.0f, 0.0f);
 *   float d = vec3_dot(a, b);  // 0.0 — perpendicular
 *
 * See: lessons/math/01-vectors
 */
static inline float vec3_dot(vec3 a, vec3 b)
{
    return a.x * b.x + a.y * b.y + a.z * b.z;
}

If the function already exists, improve documentation or skip this step.

7. Update project files

  • CMakeLists.txt (root): Add add_subdirectory(lessons/math/NN-concept-name)
  • lessons/math/README.md: Add link to the new lesson (create this file if it doesn't exist)
  • PLAN.md: Note the math lesson if relevant

8. Cross-reference GPU lessons

  • Find GPU lessons using this math: Search for where these functions are (or should be) used
  • Update GPU lesson READMEs: Add references to the math lesson
  • Update math lesson README: List GPU lessons that use this math

9. Build and test

bash
cmake -B build
cmake --build build --config Debug
./build/lessons/math/NN-concept-name/NN-concept-name

Verify the demo runs and produces expected output.

10. Verify key topics are fully explained

Before finalizing, launch a verification agent (Task agent) that audits every key topic in the README for completeness. This catches cases where a key topic name-drops a term (like "similar triangles") but the lesson never actually explains what that term means — leaving readers confused.

For each key topic / "What you'll learn" bullet, the agent must check:

  1. Explained in the README — Is the concept described clearly enough that a reader encountering it for the first time could understand it? Look in "The Math" section, key concepts, and any subsections.
  2. Demonstrated in the C program — Does main.c actually exercise this concept with code and output? A key topic that's only mentioned in the README but never shown in the demo is incomplete.
  3. All referenced terms are defined — Read the exact wording of each key topic and identify every math term, technical term, or concept it references (e.g., "similar triangles", "homogeneous coordinates", "affine transformation", "orthonormal basis"). For each referenced term, confirm it is explained somewhere in the lesson — either inline where first used, in its own subsection, or with a cross-reference to another lesson that covers it.

What to flag:

  • A key topic references a term that is never defined or explained anywhere in the README
  • A key topic is listed in "What you'll learn" but has no corresponding section in "The Math" or the demo program
  • A term is used as though the reader already knows it, but no prior math lesson in the curriculum covers it either
  • The C program prints results for a concept but the README doesn't explain how to interpret those results (or vice versa)

How to fix flagged issues:

  • Add a brief, plain-language explanation where the term is first used (1-3 sentences is usually enough — not a full derivation, just enough for the reader to follow along)
  • If the term deserves a deeper treatment, add a focused subsection under "The Math" and link to it from the key topic
  • If a prior lesson already covers the term, add an explicit cross-reference: "See Lesson NN — Name for an explanation of [term]"
  • If a key topic has no demo coverage, either add it to main.c or remove/revise the key topic to match what the lesson actually teaches

The lesson is not complete until every key topic passes all three checks.

11. Run markdown linting

Use the /dev-markdown-lint skill to check all markdown files:

bash
npx markdownlint-cli2 "**/*.md"

If errors are found:

  1. Try auto-fix: npx markdownlint-cli2 --fix "**/*.md"
  2. Manually fix remaining errors (especially MD040 - missing language tags)
  3. Verify: npx markdownlint-cli2 "**/*.md"

Common fixes needed:

  • Add language tags to code blocks (```text, ```c, ```bash)
  • Use 4 backticks for nested code blocks (when showing markdown in markdown)

MANDATORY: Chunked writes for large files

Task agents have a 32K output token limit per Write call. Any file over ~800 lines MUST be written in chunks — split into parts, write each to /tmp/, then concatenate.

Recovery rule — if a writing agent fails with a token limit error:

  • NEVER write a fallback or simplified version. STOP and report the failure.
  • Re-run the write using the chunked approach.

See .claude/large-file-strategy.md for the full strategy.

Math Library Conventions

Coordinate System

  • Right-handed, Y-up: +X right, +Y up, +Z forward
  • CCW winding: Front faces have counter-clockwise vertices

Matrix Layout

  • Column-major storage and math (matches HLSL)
  • Multiplication: v' = M * v
  • Transform order: C = A * B means "apply B first, then A"

Naming

  • vec2, vec3, vec4, mat4 — types
  • vec3_add, mat4_rotate_z — functions
  • No abbreviations except standard terms (vec, mat, lerp)

Documentation Standard

Every function needs:

  1. Summary sentence
  2. Parameter descriptions (if not obvious)
  3. Return value explanation
  4. Geometric intuition
  5. Usage example
  6. Reference to math lesson

Example: Adding Vector Operations

Scenario: Lesson 02 needs vec2 and vec3 for vertex positions and colors.

  1. Check library: vec2 and vec3 types exist, basic ops exist
  2. Determine scope: Need create, add, scale, normalize, dot, lerp
  3. Create lesson: lessons/math/01-vectors/
  4. Demo program: Print dot products of various vector pairs, show perpendicular/parallel cases
  5. README: Explain vectors, dot product, normalization with geometric intuition
  6. Update library: Add any missing vector operations with full documentation
  7. Cross-reference: Note that Lesson 02 uses vec2_create and vec3_create
  8. Build and test: Verify demo runs

Example: Extracting Math from a GPU Lesson

Scenario: You're reviewing Lesson 03 and notice it has bespoke rotation math.

  1. Identify the math: 2D rotation using sin/cos
  2. Check library: mat4_rotate_z exists!
  3. Decision: Don't create a new lesson for rotation yet (matrices lesson will cover it)
  4. Refactor Lesson 03: Replace bespoke math with mat4_rotate_z
  5. Plan: Add matrices lesson later (lesson 05-matrices)

Tips

  • Start simple: Basic operations (add, dot, normalize) before advanced (quaternions, projections)
  • One concept per lesson: Don't combine vectors and matrices in one lesson
  • Visual when possible: Showing rotations/transformations visually is more intuitive than printing numbers
  • Cross-reference extensively: Help users connect math theory to GPU practice
  • Readable code: This is teaching code, not production — clarity over performance
  • ASCII-only output: Use only ASCII characters in printf output for cross-platform compatibility (Windows Terminal may not render Unicode correctly)
  • Example output accuracy: If including example output in README, copy it directly from the actual program—don't manually type it. Learners will compare their output to yours.

Diagrams and Formulas

Find opportunities to create compelling diagrams and visualizations via the matplotlib scripts — they increase reader engagement and help learners understand the topics being taught. Use the /dev-create-diagram skill to add diagrams following the project's visual identity and quality standards.

Matplotlib diagrams

For geometric or mathematical visuals (vector diagrams, interpolation grids, frustum views), add a diagram function to scripts/forge_diagrams/math/lesson_NN.py (create the file if it doesn't exist):

  1. Write a function following the existing pattern (shared setup_axes, draw_vector, save helpers from _common.py)
  2. Re-export from scripts/forge_diagrams/math/__init__.py
  3. Import and register in the DIAGRAMS dict in __main__.py with the lesson key
  4. Run python scripts/forge_diagrams --lesson math/NN to generate the PNG
  5. Reference in the README: ![Description](assets/diagram_name.png)

Output goes to each lesson's assets/ directory at 200 DPI (PNG only).

Mermaid diagrams

For flow/pipeline diagrams (transformation pipelines, data flow), use inline mermaid blocks. GitHub renders these natively:

markdown
```mermaid
flowchart LR
    A[Step 1] --> B[Step 2] --> C[Step 3]
```

Use mermaid for sequential flows.

KaTeX math

For formulas, use inline $...$ and display $$...$$ math notation. GitHub renders these via KaTeX:

  • Inline: $\vec{a} \cdot \vec{b} = a_x b_x + a_y b_y$
  • Display math blocks must be split across three lines (CI enforces this):
text
$$
\text{lerp}(a, b, t) = a + t \cdot (b - a)
$$

Keep worked-examples-with-numbers in ```text blocks — only convert symbolic/algebraic formulas to KaTeX.

When NOT to Create a Lesson

  • The math already exists and is well-documented
  • The operation is too trivial (e.g., vec3_create — just document it in existing lessons)
  • The concept requires prerequisite lessons that don't exist yet
  • It's GPU-specific, not pure math (belongs in a GPU lesson, not math lesson)

In these cases, just update documentation or plan for later.

Câu hỏi thường gặp

Kỹ năng AI Dev Math Lesson làm được gì?

Add a math concept - create lesson, update library, document usage

Vì sao nên dùng Dev Math Lesson trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Dev Math Lesson là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Dev Math Lesson trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Nebulavenus/forge-gpu/tree/main/.claude/skills/dev-math-lesson. TypingMind đọc tệp SKILL.md và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Dev Math Lesson?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Dev Math Lesson với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Dev Math Lesson với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Dev Math Lesson có miễn phí không?

Có. Kỹ năng này được Nebulavenus phát hành trên GitHub theo giấy phép Zlib. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇