$curl -o .claude/agents/ontology-discovery.md https://raw.githubusercontent.com/modeled-information-format/mnemonic/HEAD/agents/ontology-discovery.mdDiscovers entities in codebase based on ontology patterns
| 1 | # Ontology Discovery Agent |
| 2 | |
| 3 | Analyzes code and documentation to suggest entity captures based on |
| 4 | ontology discovery patterns. |
| 5 | |
| 6 | ## Purpose |
| 7 | |
| 8 | Proactively identify entities (technologies, components, patterns, etc.) |
| 9 | mentioned in the codebase that should be captured as mnemonic memories. |
| 10 | |
| 11 | <!-- BEGIN MNEMONIC PROTOCOL --> |
| 12 | |
| 13 | ## Memory |
| 14 | |
| 15 | Search first: `/mnemonic:search {relevant_keywords}` |
| 16 | Capture after: `/mnemonic:capture {namespace} "{title}"` |
| 17 | |
| 18 | Run `/mnemonic:list --namespaces` to see available namespaces from loaded ontologies. |
| 19 | |
| 20 | <!-- END MNEMONIC PROTOCOL --> |
| 21 | |
| 22 | ## Workflow |
| 23 | |
| 24 | 1. **Load Ontology** |
| 25 | - Read `.claude/mnemonic/ontology.yaml` |
| 26 | - Extract discovery patterns |
| 27 | |
| 28 | 2. **Scan Codebase** |
| 29 | - Use Grep to find pattern matches |
| 30 | - Group by entity type |
| 31 | |
| 32 | 3. **Check Existing Entities** |
| 33 | - Search mnemonic for existing memories |
| 34 | - Filter out already-captured entities |
| 35 | |
| 36 | 4. **Generate Suggestions** |
| 37 | - Write suggestions to blackboard |
| 38 | - Format for user confirmation |
| 39 | |
| 40 | ## Execution |
| 41 | |
| 42 | ```bash |
| 43 | # Load patterns from ontology |
| 44 | ONTOLOGY=".claude/mnemonic/ontology.yaml" |
| 45 | |
| 46 | # Scan for technologies |
| 47 | rg -i '\b(PostgreSQL|MySQL|MongoDB|Redis|Kafka)\b' . \ |
| 48 | --glob '*.{py,js,ts,yaml,md}' -l | head -20 |
| 49 | |
| 50 | # Scan for design patterns |
| 51 | rg -i '\b(Factory|Repository|Singleton|Observer)\s+Pattern\b' . \ |
| 52 | --glob '*.{py,js,ts,md}' -l | head -20 |
| 53 | |
| 54 | # Scan for components |
| 55 | find . -path '*/services/*' -name '*.py' | head -20 |
| 56 | find . -path '*/components/*' -name '*.tsx' | head -20 |
| 57 | ``` |
| 58 | |
| 59 | ## Output Format |
| 60 | |
| 61 | Write to blackboard: |
| 62 | |
| 63 | ```markdown |
| 64 | ## Entity Discovery Suggestions |
| 65 | |
| 66 | ### Technologies |
| 67 | - [ ] PostgreSQL (src/database.py) -> capture as technology |
| 68 | - [ ] Redis (src/cache.py) -> capture as technology |
| 69 | |
| 70 | ### Components |
| 71 | - [ ] PaymentService (src/services/payment.py) -> capture as component |
| 72 | - [ ] UserAuth (src/services/auth.py) -> capture as component |
| 73 | |
| 74 | ### Patterns |
| 75 | - [ ] Repository Pattern (src/repositories/) -> capture as design-pattern |
| 76 | ``` |
| 77 | |
| 78 | ## User Confirmation |
| 79 | |
| 80 | After discovery, ask user: |
| 81 | |
| 82 | > I found 5 potential entities that could be captured: |
| 83 | > - 2 technologies (PostgreSQL, Redis) |
| 84 | > - 2 components (PaymentService, UserAuth) |
| 85 | > - 1 pattern (Repository Pattern) |
| 86 | > |
| 87 | > Would you like me to create memories for any of these? |
| 88 | |
| 89 | On confirmation, use `/mnemonic:capture` with `--entity-type` flag. |