grace-explainer
npx machina-cli add skill osovv/grace-marketplace/grace-explainer --openclawGRACE — Graph-RAG Anchored Code Engineering
GRACE is a methodology for AI-driven code generation that makes codebases navigable by LLMs. It solves the core problem of AI coding assistants: they generate code but can't reliably navigate, maintain, or evolve it across sessions.
The Problem GRACE Solves
LLMs lose context between sessions. Without structure:
- They don't know what modules exist or how they connect
- They generate code that duplicates or contradicts existing code
- They can't trace bugs through the codebase
- They drift from the original architecture over time
GRACE provides three interlocking systems that fix this:
Knowledge Graph (docs/knowledge-graph.xml)
↓ maps modules, dependencies, exports
Module Contracts (MODULE_CONTRACT in each file)
↓ defines WHAT each module does
Semantic Markup (START_BLOCK / END_BLOCK in code)
↓ makes code navigable at ~500 token granularity
Five Core Principles
1. Never Write Code Without a Contract
Before generating any module, create its MODULE_CONTRACT with PURPOSE, SCOPE, INPUTS, OUTPUTS. The contract is the source of truth — code implements the contract, not the other way around.
2. Semantic Markup Is Not Comments
Markers like // START_BLOCK_<NAME> and // END_BLOCK_<NAME> are navigation anchors, not documentation. They serve as attention anchors for LLM context management and retrieval points for RAG systems.
3. Knowledge Graph Is Always Current
docs/knowledge-graph.xml is the single map of the entire project. When you add a module — add it to the graph. When you add a dependency — add a CrossLink. The graph never drifts from reality.
4. Top-Down Synthesis
Code generation follows a strict pipeline:
Requirements → Technology → Development Plan → Module Contracts → Code
Never jump to code. If requirements are unclear — stop and clarify.
5. Governed Autonomy (PCAM)
- Purpose: defined by the contract (WHAT to build)
- Constraints: defined by the development plan (BOUNDARIES)
- Autonomy: you choose HOW to implement
- Metrics: the contract's outputs tell you if you're done
You have freedom in HOW, not in WHAT. If a contract seems wrong — propose a change, don't silently deviate.
How the Elements Connect
docs/requirements.xml — WHAT the user needs (use cases, AAG notation)
↓
docs/technology.xml — WHAT tools we use (runtime, language, versions)
↓
docs/development-plan.xml — HOW we structure it (modules, phases, contracts)
↓
docs/knowledge-graph.xml — MAP of everything (modules, dependencies, exports)
↓
src/**/* — CODE with GRACE markup (contracts, blocks, maps)
Each layer feeds the next. The knowledge graph is both an output of planning and an input for code generation.
Development Workflow
/grace:init— create docs/ structure and CLAUDE.md- Fill in
requirements.xmlwith use cases - Fill in
technology.xmlwith stack decisions /grace:plan— architect modules, generate development plan and knowledge graph/grace:generate <module>— generate one module with full markup/grace:execute— generate all modules with review and commits/grace:refresh— sync knowledge graph after manual changes/grace:fix <error>— debug via semantic navigation/grace:status— health report
Detailed References
For in-depth documentation on each GRACE component, see the reference files in this skill's references/ directory:
references/semantic-markup.md— Block conventions, granularity rules, loggingreferences/knowledge-graph.md— Graph structure, module types, CrossLinks, maintenancereferences/contract-driven-dev.md— MODULE_CONTRACT, function contracts, PCAMreferences/unique-tag-convention.md— Unique ID-based XML tags, why they work, full naming table
Source
git clone https://github.com/osovv/grace-marketplace/blob/main/plugins/grace/skills/grace-explainer/SKILL.mdView on GitHub Overview
Provides a complete GRACE methodology reference to explain the framework, onboard new projects, and understand its components. It covers knowledge graphs, module contracts, semantic markup, and the unique tag conventions that keep a codebase navigable for LLMs.
How This Skill Works
Condenses GRACE into core concepts: a live knowledge graph (docs/knowledge-graph.xml), MODULE_CONTRACTs in each file, and semantic START_BLOCK/END_BLOCK markers. It also maps the five principles and the top-down synthesis pipeline (Requirements → Technology → Development Plan → Module Contracts → Code) plus Governed Autonomy (PCAM) to guide safe coding.
When to Use It
- Onboarding new GRACE projects and teams to align on contracts, graphs, and markup
- Explaining GRACE to users or stakeholders to show how navigation and governance work
- Reviewing how modules, contracts, and semantic markup interoperate during planning
- Guiding code generation with the top-down pipeline and PCAM governance
- Auditing the knowledge graph and CrossLinks after changes or deployments
Quick Start
- Step 1: Review or create the MODULE_CONTRACT for the target module with PURPOSE, SCOPE, INPUTS, OUTPUTS
- Step 2: Add semantic blocks in code using START_BLOCK_<NAME> and END_BLOCK_<NAME> markers for navigation
- Step 3: Update docs/knowledge-graph.xml and follow the grace workflow to generate and sync
Best Practices
- Always create a MODULE_CONTRACT with PURPOSE, SCOPE, INPUTS, OUTPUTS before coding
- Treat START_BLOCK_<NAME> and END_BLOCK_<NAME> as navigation anchors, not comments
- Keep docs/knowledge-graph.xml in sync with new modules and dependencies
- Follow the Top-Down Synthesis order: Requirements → Technology → Development Plan → Module Contracts → Code
- Apply Governed Autonomy (PCAM): fix or adjust contracts before deviating, measure completion by contract outputs
Example Use Cases
- Onboarding a new team by mapping modules, contracts, and the knowledge graph
- Explaining a module’s contract to users to show inputs/outputs and purposes
- Adding a new feature with a MODULE_CONTRACT and updating knowledge-graph.xml
- Using START_BLOCK/END_BLOCK markers to navigate and review a codebase
- Running grace workflow steps: /grace:init, /grace:plan, /grace:generate, /grace:execute