Skip to content

Commit 2753490

Browse files
committed
docs: restore alef skill
1 parent db7dbca commit 2753490

1 file changed

Lines changed: 235 additions & 0 deletions

File tree

skills/alef/SKILL.md

Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
---
2+
name: alef
3+
description: >-
4+
Use Alef correctly for Rust-to-polyglot binding generation. Trigger when
5+
configuring alef.toml, generating bindings, READMEs, API/CLI/MCP docs,
6+
llms.txt, agent skills, e2e suites, or debugging stale/missing generated
7+
output in Alef-powered repositories. Covers the safe command sequence,
8+
config ownership, generated-output rules, snippet validation, downstream
9+
smoke testing, and Alef development workflow.
10+
license: MIT
11+
metadata:
12+
author: xberg-io
13+
version: "1.0"
14+
repository: https://github.com/xberg-io/alef
15+
---
16+
17+
# Alef
18+
19+
Alef extracts a Rust public API surface and generates language-native bindings,
20+
package scaffolding, type stubs, READMEs, docs, e2e tests, and release metadata
21+
from `alef.toml`.
22+
23+
Use this skill when working in Alef itself or in a downstream repo that uses
24+
Alef.
25+
26+
## Core Rules
27+
28+
- Treat Rust source plus `alef.toml` as the source of truth.
29+
- Read the local `alef.toml` before proposing config or generation changes.
30+
- Do not hand-edit Alef-managed generated files except when adopting an existing
31+
file into Alef management.
32+
- Preserve user changes in dirty worktrees. Stage and commit only the requested
33+
scope.
34+
- Prefer narrow commands while iterating, then run the broader verification
35+
command before committing.
36+
- For user-visible Alef behavior changes, update `CHANGELOG.md`.
37+
38+
## Standard Consumer Workflow
39+
40+
From a repo that uses Alef:
41+
42+
```bash
43+
alef generate --format
44+
alef scaffold
45+
alef readme
46+
alef docs
47+
alef verify --exit-code
48+
```
49+
50+
Use the combined command when a full refresh is expected:
51+
52+
```bash
53+
alef all --format
54+
```
55+
56+
Use filters to keep iteration small:
57+
58+
```bash
59+
alef generate --lang python,node
60+
alef docs --output docs/reference
61+
alef test --lang python
62+
alef verify --exit-code
63+
```
64+
65+
When testing an unreleased local Alef from a sibling repo, run the binary through
66+
Cargo instead of using the installed version:
67+
68+
```bash
69+
cargo run -q --manifest-path ../alef/Cargo.toml -- docs
70+
cargo run -q --manifest-path ../alef/Cargo.toml -- all --format
71+
```
72+
73+
## Config Model
74+
75+
Current Alef configs use:
76+
77+
- `[workspace]` for shared languages, tools, DTO defaults, docs defaults, and
78+
pipeline defaults.
79+
- `[[crates]]` for each generated package/API surface.
80+
- `[crates.<language>]` or `[workspace.<language>]` for target-specific output,
81+
package names, feature flags, excludes, and stubs.
82+
- `source_crates` when a facade crate re-exports API from multiple Rust crates.
83+
- `features` when cfg-gated public fields/types must be considered present.
84+
85+
Use `include` for small curated APIs. Use `exclude` for large APIs where most
86+
public items should bind except known internal, generic, trait, or unsupported
87+
items.
88+
89+
## Generated Docs, llms.txt, and Skills
90+
91+
Alef can generate docs in this order:
92+
93+
1. API reference docs from extracted Rust API.
94+
2. CLI reference docs from configured Clap sources.
95+
3. MCP reference docs from configured rmcp-style sources.
96+
4. Snippet index and configured snippet validation.
97+
5. Template-rendered `llms.txt`.
98+
6. Template-rendered grouped skills.
99+
100+
Important rules:
101+
102+
- `llms.txt` and skills are template-owned. Missing templates are hard errors.
103+
- Alef should not invent full prose for `llms.txt` or skills.
104+
- Existing unmanaged outputs require explicit `adopt_existing = true`.
105+
- Generated Markdown keeps frontmatter first, then Alef's managed hash marker.
106+
- Warn only for actionable skips: missing configured sources, configured
107+
extractors discovering nothing, missing configured snippet dirs, or unavailable
108+
snippet toolchains.
109+
110+
Common docs config shape:
111+
112+
```toml
113+
[workspace.docs]
114+
reference_output = "docs/reference"
115+
116+
[workspace.docs.cli]
117+
sources = ["crates/my-cli/src/main.rs"]
118+
119+
[workspace.docs.mcp]
120+
sources = ["crates/my-lib/src/mcp/server.rs"]
121+
122+
[workspace.docs.llms]
123+
template = "templates/docs/llms.txt.jinja"
124+
output = "docs/llms.txt"
125+
adopt_existing = true
126+
127+
[workspace.docs.skills]
128+
template_dir = "templates/docs/skills"
129+
outputs = [".codex/skills", ".agents/skills", ".claude/skills", ".github/skills"]
130+
adopt_existing = true
131+
132+
[workspace.docs.snippets]
133+
dirs = ["docs/snippets"]
134+
docs_dirs = ["docs"]
135+
required_languages = ["python", "rust"]
136+
validation_level = "syntax"
137+
```
138+
139+
Skill templates default to grouped `api`, `cli`, and `mcp` skills:
140+
141+
```text
142+
templates/docs/skills/
143+
├── api/SKILL.md.jinja
144+
├── cli/SKILL.md.jinja
145+
└── mcp/SKILL.md.jinja
146+
```
147+
148+
## Snippets
149+
150+
Use snippets as maintained examples, not generated filler. Configure validation
151+
instead of silently trusting examples:
152+
153+
- `dirs`: snippet roots.
154+
- `docs_dirs`: docs/template roots to scan for includes.
155+
- `required_languages`: language variants every grouped snippet should have.
156+
- `validation_level`: `syntax`, `typecheck`, `compile`, or `run`.
157+
- `include_base_paths`: paths matching MkDocs snippet include roots.
158+
159+
Unreferenced snippets should normally warn, not fail. Missing references,
160+
missing required language variants, unknown languages, and skip annotations
161+
without reasons should fail.
162+
163+
## Debugging
164+
165+
Missing type or function:
166+
167+
```bash
168+
alef extract -o /tmp/api.json
169+
jq '.types | keys' /tmp/api.json
170+
```
171+
172+
Then check:
173+
174+
- Is the source file listed in `sources` or `source_crates`?
175+
- Is the item public and reachable from the configured source?
176+
- Is it excluded in config or with an Alef attribute?
177+
- Does it depend on an unsupported generic, trait object, or external type?
178+
- Does the target language need an FFI layer (`ffi`) or explicit type mapping?
179+
180+
Stale output:
181+
182+
```bash
183+
alef verify --exit-code
184+
alef diff
185+
alef generate --clean --format
186+
```
187+
188+
Cache issues:
189+
190+
```bash
191+
rm -rf .alef
192+
alef generate --clean --format
193+
```
194+
195+
Docs generation issues:
196+
197+
- Confirm template paths are relative to the workspace root.
198+
- Confirm configured CLI/MCP source paths exist.
199+
- Confirm generated outputs have Alef headers or `adopt_existing = true`.
200+
- Use `-v`/`RUST_LOG` when a warning is expected but not visible.
201+
202+
## Working on Alef Itself
203+
204+
In the Alef repo, prefer focused checks while iterating:
205+
206+
```bash
207+
cargo fmt
208+
cargo check -q
209+
cargo test -q docs:: -- --nocapture
210+
cargo test -q <module_or_test_name>
211+
```
212+
213+
Before committing behavior changes, run the highest-signal relevant tests. For
214+
docs/template work, also smoke test downstream repos with the local binary:
215+
216+
```bash
217+
cargo run -q --manifest-path ../alef/Cargo.toml -- docs
218+
git diff --check
219+
```
220+
221+
Use the sibling repos that exercise Alef broadly:
222+
223+
- `../crawlberg`
224+
- `../html-to-markdown`
225+
- `../liter-llm`
226+
- `../tree-sitter-language-pack`
227+
228+
Do not include `../xberg` unless explicitly asked.
229+
230+
## Release Notes and Commits
231+
232+
- Update `CHANGELOG.md` under `[Unreleased]` for user-visible changes.
233+
- Keep release commits separate from feature/fix commits.
234+
- Do not add AI attribution to commits, tags, or release notes.
235+
- Use the existing release procedure skill when cutting a version.

0 commit comments

Comments
 (0)