Skip to content
Open
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
141 changes: 141 additions & 0 deletions .agents/skills/grilly/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
```markdown
# grilly Development Patterns

> Auto-generated skill from repository analysis

## Overview
This skill teaches the core development patterns, coding conventions, and common workflows used in the `grilly` codebase. `grilly` is a Python-centric project (with C++ and shader components) focused on autograd operations, GPU acceleration, and integration between Python and C++. The repository emphasizes modularity, clear commit practices, and a workflow-driven approach to adding features and documenting progress.

## Coding Conventions

- **File Naming:**
Use `snake_case` for all Python and script files.
*Example:*
```
test_backward_rmsnorm.py
train_linear_ce.py
```

- **Import Style:**
Prefer **relative imports** within Python modules.
*Example:*
```python
from .core import Tensor
from .autograd import backward_rmsnorm
```

- **Export Style:**
Use **named exports** for functions and classes.
*Example:*
```python
def backward_rmsnorm(...):
...
```

- **Commit Messages:**
- Freeform, but often start with prefixes like `autograd`, `docs`, `integration`, `todo`.
- Average commit message length: ~69 characters.

## Workflows

### Add New Autograd Operation
**Trigger:** When adding support for a new operation to the autograd engine (e.g., `backward_rmsnorm`, `forward_linear`).
**Command:** `/new-autograd-op`

1. Implement or add new GLSL shader(s) for the operation if needed.
*Example:* `shaders/rms-norm-backward.glsl`
2. Compile GLSL to SPIR-V if required.
*Example:* `shaders/spv/rms-norm-backward.spv`
3. Update C++ autograd headers and source to add the handler.
- `cpp/include/grilly/autograd/autograd.h`
- `cpp/src/autograd.cpp`
4. Wire the operation into Python bindings.
- `cpp/python/bindings_autograd.cpp`
5. Add or update a test for the new op.
*Example:* `test_backward_rmsnorm.py`

---

### Document Autograd State or Milestone
**Trigger:** When completing a significant feature, bugfix, or integration step and wanting to record the project state.
**Command:** `/update-state-doc`

1. Edit `AUTOGRAD_STATE.md` to describe new features, bugfixes, or integration steps.
2. Optionally update `TODO.md` or related docs.
3. Commit the documentation.

---

### Integration Test or Training Script Addition
**Trigger:** When verifying that a new feature or workflow works in a real training or integration scenario.
**Command:** `/add-integration-test`

1. Add or update a script in `experimental/resident_train/`.
*Example:* `train_linear_ce.py`
2. Run the script to verify integration.
3. Optionally update documentation with results.

---

### Add or Update Python-C++ Binding
**Trigger:** When adding a new C++ feature that needs to be exposed to Python.
**Command:** `/add-python-binding`

1. Implement or update binding in `cpp/python/`.
*Example:* `bindings_autograd.cpp`, `bindings_core.cpp`
2. Update `CMakeLists.txt` if new binding files are added.
3. Optionally add a Python test or usage example.

---

### Add or Update Shader and SPIR-V
**Trigger:** When implementing a new GPU operation or updating an existing one.
**Command:** `/add-shader`

1. Write or modify a GLSL shader in `shaders/*.glsl`.
2. Compile to SPIR-V and add/update `shaders/spv/*.spv`.
3. Wire up usage in C++ and/or Python if needed.

---

### Add or Update TODO or Workboard
**Trigger:** When recording new tasks, marking tasks as done, or updating project planning.
**Command:** `/update-todo`

1. Edit `TODO.md` to add, update, or mark tasks as done.
2. Commit `TODO.md`.

---

## Testing Patterns

- **Framework:** Unknown (no standard Python test framework detected).
- **File Pattern:** Python test files use the pattern `test_*.py`.
- **Integration Tests:** Often placed in `experimental/resident_train/`.
- **Other Patterns:** Some references to `*.test.ts` (TypeScript), but main tests appear to be Python scripts.

*Example test file:*
```python
# test_backward_rmsnorm.py
from .autograd import backward_rmsnorm

def test_backward_rmsnorm_basic():
# Setup input tensors
...
# Call the function
result = backward_rmsnorm(...)
# Assert correctness
assert ...
```

## Commands

| Command | Purpose |
|----------------------|----------------------------------------------------------------|
| /new-autograd-op | Add a new autograd operation (forward/backward) |
| /update-state-doc | Update project state documentation (AUTOGRAD_STATE.md, TODO.md)|
| /add-integration-test| Add or update an integration test or training script |
| /add-python-binding | Add or update Python-C++ bindings |
| /add-shader | Add or update a GLSL shader and its SPIR-V binary |
| /update-todo | Update TODO.md or project workboard |
```
6 changes: 6 additions & 0 deletions .agents/skills/grilly/agents/openai.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
interface:
display_name: "Grilly"
short_description: "Repo-specific patterns and workflows for grilly"
default_prompt: "Use the grilly repo skill to follow existing architecture, testing, and workflow conventions."
policy:
allow_implicit_invocation: true
41 changes: 41 additions & 0 deletions .claude/commands/add-new-autograd-op.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
name: add-new-autograd-op
description: Workflow command scaffold for add-new-autograd-op in grilly.
allowed_tools: ["Bash", "Read", "Write", "Grep", "Glob"]
---

# /add-new-autograd-op

Use this workflow when working on **add-new-autograd-op** in `grilly`.

## Goal

Implements a new autograd operation (forward/backward) or wires an existing shader into the autograd engine, including Python bindings and tests.

## Common Files

- `cpp/include/grilly/autograd/autograd.h`
- `cpp/src/autograd.cpp`
- `cpp/python/bindings_autograd.cpp`
- `shaders/*.glsl`
- `shaders/spv/*.spv`
- `test_*.py`

## Suggested Sequence

1. Understand the current state and failure mode before editing.
2. Make the smallest coherent change that satisfies the workflow goal.
3. Run the most relevant verification for touched files.
4. Summarize what changed and what still needs review.

## Typical Commit Signals

- Implement or add new GLSL shader(s) for the operation if needed (e.g., shaders/rms-norm-backward.glsl, shaders/spv/rms-norm-backward.spv)
- Update C++ autograd headers and source to add the handler (cpp/include/grilly/autograd/autograd.h, cpp/src/autograd.cpp)
- Wire the operation into Python bindings (cpp/python/bindings_autograd.cpp)
- Add or update a test for the new op (e.g., test_backward_rmsnorm.py, test_backward_swiglu.py, etc.)

## Notes

- Treat this as a scaffold, not a hard-coded script.
- Update the command if the workflow evolves materially.
35 changes: 35 additions & 0 deletions .claude/commands/feature-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: feature-development
description: Workflow command scaffold for feature-development in grilly.
allowed_tools: ["Bash", "Read", "Write", "Grep", "Glob"]
---

# /feature-development

Use this workflow when working on **feature-development** in `grilly`.

## Goal

Standard feature implementation workflow

## Common Files

- `**/*.test.*`

## Suggested Sequence

1. Understand the current state and failure mode before editing.
2. Make the smallest coherent change that satisfies the workflow goal.
3. Run the most relevant verification for touched files.
4. Summarize what changed and what still needs review.

## Typical Commit Signals

- Add feature implementation
- Add tests for feature
- Update documentation

## Notes

- Treat this as a scaffold, not a hard-coded script.
- Update the command if the workflow evolves materially.
37 changes: 37 additions & 0 deletions .claude/commands/test-driven-development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
name: test-driven-development
description: Workflow command scaffold for test-driven-development in grilly.
allowed_tools: ["Bash", "Read", "Write", "Grep", "Glob"]
---

# /test-driven-development

Use this workflow when working on **test-driven-development** in `grilly`.

## Goal

Test-first development workflow (TDD)

## Common Files

- `**/*.test.*`
- `**/*.spec.*`
- `src/**/*`

## Suggested Sequence

1. Understand the current state and failure mode before editing.
2. Make the smallest coherent change that satisfies the workflow goal.
3. Run the most relevant verification for touched files.
4. Summarize what changed and what still needs review.

## Typical Commit Signals

- Write failing test
- Implement code to pass test
- Refactor if needed

## Notes

- Treat this as a scaffold, not a hard-coded script.
- Update the command if the workflow evolves materially.
Loading
Loading