{"data":{"slug":"github-xberg-io-xberg-ai-rulez-skills-alef-generated-bindings-45b96fdee3e3","title":"Regenerate Alef Bindings for Cross-Language Compatibility","summary":"Automate the regeneration of Alef bindings for multiple languages, ensuring consistency across Rust, Python, Node.js, and other platforms.","url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-alef-generated-bindings-45b96fdee3e3","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-xberg-io-xberg-ai-rulez-skills-alef-generated-bindings-45b96fdee3e3","markdown_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-alef-generated-bindings-45b96fdee3e3.md","download_url":"https:\/\/skillshunter.net\/skills\/github-xberg-io-xberg-ai-rulez-skills-alef-generated-bindings-45b96fdee3e3\/download","category":{"slug":"software-development","name":"Software & Development"},"editor_note":"Ensure `alef.toml` is updated before modifying any binding crate or `packages\/*` directory. Regenerate with `alef all --clean --skip-compile --skip-snippet-validation` after making changes.","instructions":"---\ntype: Playbook\ntitle: Alef Generated Bindings\ndescription: \"Edit Alef bindings: output paths, configuration, core regeneration and FFI JSON.\"\npaths:\n  - \"alef.toml\"\n  - \"packages\/**\"\n  - \"crates\/xberg-ffi\/**\"\n  - \"crates\/xberg-py\/**\"\n  - \"crates\/xberg-node\/**\"\n  - \"crates\/xberg-php\/**\"\n  - \"crates\/xberg-jni\/**\"\n  - \"crates\/xberg-wasm\/**\"\n  - \"crates\/xberg\/src\/extractors\/**\"\n  - \"crates\/xberg\/src\/plugins\/**\"\nx-ai-rulez:\n  kind: skill\n  id: alef-generated-bindings\n  metadata:\n    name: alef-generated-bindings\n---\n\n# Alef-Generated Bindings\n\nXberg specifics on top of the shared Alef workflow skill (generic regenerate\/verify\/commit loop).\n\n- Check `alef.toml` before touching anything in `packages\/*\/` or a binding crate.\n- Regenerate with `alef all --clean --skip-compile --skip-snippet-validation` (after\n  `mise run dart:format:context`); it formats via poly. There is no `alef:generate` or `alef:format` task.\n- `mise run alef:verify` runs `alef verify --exit-code`.\n- Run `alef docs` directly to generate API documentation.\n- The `alef:*` namespace is exactly: `verify`, `build`, `verify:readme-paths`, `verify:ffi-formats`,\n  `verify:fields`.\n\n## Freshness check\n\n`mise run alef:verify`. A hand-rolled `git diff` over `packages\/` is under-scoped \u2014 generated\noutput also lands in `crates\/xberg-py\/`, `crates\/xberg-php\/`, `crates\/xberg-jni\/`,\n`crates\/xberg-node\/`, `crates\/xberg-wasm\/`, `crates\/xberg-ffi\/`, `packages\/dart\/rust\/`,\n`packages\/swift\/rust\/`, and `e2e\/`.\n\nEach generated file carries an `\/\/ alef:hash:` header that `alef verify` recomputes; `.alef\/`\n(`sources_hash.cache`, `hashes\/`) is a gitignored local cache, empty in a new worktree.\nNeither makes a generated file safe to hand-fix \u2014 a regen restores it. Fix `alef.toml` or the\nRust source, then regenerate and re-verify.\n\n## Key `alef.toml` sections\n\n- `[workspace]`, `[workspace.sync]` (version-sync `extra_paths`), `[workspace.docs]`,\n  `[workspace.poly]`, `[workspace.generate]`\n- `[[crates]]` \u2014 the Rust source crate parsed for type\/function extraction, plus\n  `[[crates.source_crates]]`\n- `[crates.<lang>]` \u2014 one table per binding: `python`, `node`, `ruby`, `php`, `elixir`,\n  `wasm`, `ffi`, `go`, `java`, `dart`, `kotlin_android`, `jni`, `swift`, `csharp`, `zig`\n  (each carrying `exclude_functions`, `target_dep_overrides`, stubs, \u2026)\n- `[crates.e2e]` \u2014 e2e generation (`output = \"e2e\"`, `[crates.e2e.call.overrides.<lang>]`)\n- `[crates.readme]` \u2014 README generation (`template_dir = \"templates\/readme\"`,\n  `[crates.readme.languages.<lang>]`)\n- `[crates.exclude]`, `[crates.output]`, `[crates.custom_modules]`, `[crates.publish]`\n\nThere are no `[crate]`, `[languages.*]`, `[e2e]` or `[readme]` top-level tables, and\n`alef.toml` declares **no rename mappings** \u2014 the generated Go trait type is\n`DocumentExtractor`, unchanged.\n\nBesides the per-language `<lang>:e2e` tasks, this repo has `e2e:verify`.\n\n## Core-side edits that break a regen\n\n- **New extractor struct** \u2014 needs `#[cfg_attr(alef, alef(skip))]` on the struct declaration,\n  not the impl block. Without it the regen aborts globally and nothing regenerates, leaving\n  the tree silently stale. Check this first when a regen dies. (Most modules in\n  `crates\/xberg\/src\/extractors\/` carry the attribute.)\n- **Binding-facing types must not be `#[non_exhaustive]`** \u2014 alef generates\n  `impl From<Mirror> for xberg::TheType` with a struct literal in ~10 binding crates, and\n  `#[non_exhaustive]` forbids that (`E0639`). Derive `Default` for forward-compat instead.\n  Keep `#[non_exhaustive]` only on types listed in `[crates.exclude]`.\n- **A new enum variant on a binding-facing type** breaks exhaustive matches across the\n  generated binding crates.\n\n## Trait return types crossing the generated FFI bridge\n\nThe generated `XbergOcrBackendBridge` in `crates\/xberg-ffi\/src\/lib.rs` marshals **every**\ntrait method's return value through JSON (218 `serde_json::from_str::<xberg::\u2026>` call sites\ntoday) and falls back to `Default::default()` on an uninitialised vtable slot, a failing host\ncallback, or a null result. Whether a variant carries a payload is irrelevant.\n\nAdding a method to a trait with a generated bridge means its return type needs\n`Default + Serialize + Deserialize`. Unit-only enums included.\n\n`crates\/xberg-ffi` is linted in CI only by `cargo clippy --workspace` at default features. Verify a\nchange to it with the scoped `cargo check -p xberg-ffi`. That check rewrites `crates\/xberg-ffi\/include\/xberg.h` and `packages\/go\/include\/xberg.h` to\nmatch whatever feature set you invoked it with, which is usually not the committed one. Revert\nthat churn rather than committing it.\n\n## Which alef answered\n\n`alef all` runs whatever `alef` is first on `PATH`, not a `cargo run` against a\nsibling checkout; check `alef --version` against `alef.toml` `alef_version` before\nregenerating. A source fix in a sibling checkout has zero effect until it is installed. Generator fixes ship in order: land upstream \u2192 release alef\n\u2192 bump the pinned version \u2192 regen. Regenerating against a locally modified alef produces a\ntree the pinned version cannot reproduce.\n","use_cases":["Regenerate bindings after updating Rust source code","Ensure cross-language compatibility across Python, Node.js, and other platforms","Verify generated bindings against source code changes"],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/xberg-io\/xberg\/blob\/ffbf7971796a126fc52f6bb8fb40418772071f61\/.ai-rulez\/skills\/alef-generated-bindings\/SKILL.md","source_commit":"ffbf7971796a126fc52f6bb8fb40418772071f61","license":null,"version":null,"listing_approved_at":"2026-11-16","created_at":"2026-11-15T13:10:33.000000Z","updated_at":"2026-11-16T05:16:54.000000Z","seo_title":"Regenerate Alef Bindings for Cross-Language Compatibility","seo_description":"Automate Alef binding regeneration for multiple languages with precise configuration and verification workflows.","seo_keywords":["alef bindings regeneration","cross-language binding generation","rust to python binding regeneration","alef binding verification","cross-platform binding regeneration"]}}