ng-diagram-persistence
Skill by synergycodes
Explains how to save, load and restore ng-diagram diagrams in Angular using toJSON and initializeModel. It also covers custom ModelAdapter stores and the limits of undo and redo. Aimed at developers who use the ng-diagram library.
Install ng-diagram-persistence
Built from the published package, never by AI.
git clone --depth 1 https://github.com/synergycodes/ng-diagram /tmp/ng-diagram && mkdir -p ~/.claude/skills && cp -r /tmp/ng-diagram/skills/ng-diagram-persistence ~/.claude/skills/ng-diagram-persistenceRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/synergycodes/ng-diagram /tmp/ng-diagram && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/ng-diagram/skills/ng-diagram-persistence ~/.gemini/antigravity-cli/skills/ng-diagram-persistenceAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install ng-diagram-persistence in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill covers saving and loading an ng-diagram in an Angular app. It explains how NgDiagramModelService.toJSON() produces a JSON string and how initializeModel() restores it by creating a new model. It also lists which runtime properties are stripped on save and load, and which settings, listeners and middlewares are lost when a new engine starts.
It describes custom ModelAdapter implementations over your own store, wired through initializeModelAdapter(). The skill also covers autosave with an effect, a symptom-to-fix table, and the fact that undo and redo are not built in. It is aimed at developers who use the ng-diagram library and need to keep diagram data across reloads or in a backend.
Written from the project's SKILL.md and checked against it.
What it can do
- Save with toJSON()Serializes the diagram to a JSON string without runtime properties using NgDiagramModelService.toJSON().
- Load with initializeModel()Restores a saved diagram by creating a new model from parsed JSON, with an injector outside injection context.
- Stripped and kept propertiesLists which node and edge properties toJSON() removes and which it keeps, including the viewport and metadata.
- Custom ModelAdapterShows how to keep diagram data in your own store by implementing ModelAdapter and calling initializeModelAdapter().
- Autosave patternProvides an effect-based autosave example with a debounce that writes the diagram to localStorage.
- Restore after loadExplains waiting for diagramInit before calling services, and which settings and listeners are reset.
- Undo and redo design notesExplains that undo and redo must be implemented in a custom adapter and that the default model only logs a warning.
- Symptom to fix tableMaps common problems such as lost selection, lost listeners and empty diagrams to their causes and fixes.
What you need
- An Angular project
- The ng-diagram library (the skill describes version 1.4.0)
Try asking
- Save my ng-diagram to localStorage and restore it on page load
- Create a custom ModelAdapter that stores my ng-diagram nodes and edges in a backend
- Add undo and redo to my ng-diagram using a custom ModelAdapter
Good to know
- Undo and redo are not built in and need a custom ModelAdapter.
- Loading a diagram starts a new engine, so some settings and listeners must be re-applied.
- Custom strip functions are marked as at your own risk in the source.
- The skill describes ng-diagram 1.4.0 and newer features are marked by version.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: skills/ng-diagram-persistence/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Alternatives to ng-diagram-persistence
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
ng-diagram-persistence: common questions
Why does Ctrl+Z do nothing in ng-diagram?
The default model does not support undo. The source says to implement undo() and redo() in a custom ModelAdapter to get history.
Why is node selection lost after loading a saved diagram?
The source says node selected is stripped on save and on load. You can select nodes again after diagramInit or keep it with a custom strip function at your own risk.
How do I save an ng-diagram to a backend?
Send the output of NgDiagramModelService.toJSON() to the server and build the model from the response with initializeModel(data, injector).
How do I install ng-diagram-persistence?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is ng-diagram-persistence free?
The code is published under the Apache-2.0 licence. The service it connects to may have its own pricing.
Is ng-diagram-persistence safe to use?
It scores 73 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to ng-diagram-persistence?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
