google/filament-lifetime
> Enforce correct Filament object creation and destruction lifecycles. Use this skill when initializing rendering pipelines or allocating/deallocating GPU buffers and entities.
npx skills add https://github.com/google/filament --skill filament-lifetime
Filament manages its own native allocations. To prevent segmentation faults and memory leaks, follow these rules:
EntityManager directly from the Engine instance:utils::EntityManager& em = engine->getEntityManager();
Engine pointer is inaccessible:utils::EntityManager& em = utils::EntityManager::get();
utils::Entity entity = engine->getEntityManager().create();
engine->getEntityManager().destroy(entity);
RenderableManager::Builder or LightManager::Builder on the entity: RenderableManager::Builder(1)
.geometry(0, RenderableManager::PrimitiveType::TRIANGLES, vb, ib)
.material(0, matInstance)
.build(*engine, entity);
Camera* camera = engine->createCamera(entity);
First, destroy all Filament-managed components on the entity:
engine->destroy(entity);
Second, free the Entity ID:
engine->getEntityManager().destroy(entity);
// Correct Entity Cleanup
engine->destroy(myEntity);
engine->getEntityManager().destroy(myEntity);
You can destroy specific components individually without deleting the entity:
engine->destroyCameraComponent(entity);engine->getTransformManager().destroy(entity);engine->getRenderableManager().destroy(entity);Native GPU objects are created using the Engine factory or nested Builder patterns.
delete: Never call standard C++ delete on pointers returned by Engine.Engine instance.View, Scene, Renderer, SwapChain. View* view = engine->createView();
// ...
engine->destroy(view);
Builder class, passing the engine instance to build(*engine).VertexBuffer, IndexBuffer, Texture, Material, IndirectLight, Skybox, RenderTarget. VertexBuffer* vb = VertexBuffer::Builder()
.vertexCount(count)
.bufferCount(1)
.attribute(VertexAttribute::POSITION, 0, VertexBuffer::AttributeType::FLOAT3)
.build(*engine);
// ...
engine->destroy(vb);
Take google/filament-lifetime from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.