# KCode Skill Routing

> Use this file to connect `.trellis/spec` rules with KCode skills and extensions.

---

## Principle

Spec files define what must be true in this project. Skills define how to perform a complex workflow.

Do not copy long skill procedures into spec. Instead, read the relevant spec first, then load the matching skill when execution needs platform knowledge, templates, or deeper workflow.

---

## Product-Line Skills

| Scenario | Read spec | Use KCode skill |
| --- | --- | --- |
| Cosmic/BOS Java plugin or SDK work | `../backend/cosmic-java/index.md` | `ok-cosmic` |
| Cosmic Java code review | `../backend/cosmic-java/review.md` | `kd-cosmic-review` |
| Cosmic Java unit tests | `../backend/cosmic-java/testing.md` | `cosmic-unittest` |
| Cosmic KSQL or data fix | `../backend/cosmic-java/ksql.md` | `kd-ksql` |
| Enterprise C# plugin work | `../backend/enterprise/csharp-conventions.md` | `kd-enterprise-csharp` |
| Enterprise IronPython plugin work | `../backend/enterprise/python-plugin.md` | `kd-enterprise-python-plugin` |
| Enterprise OpenAPI / integration work | `../backend/enterprise/openapi-design.md` | `kd-enterprise-openapi` |

---

## Cross-Cutting Skills

| Scenario | Read spec | Use KCode skill |
| --- | --- | --- |
| **New Kingdee delivery / fuzzy plugin ask** | `project-context.md` | **`kd-grill`** → **metadata-db-query** (Agent-guided readonly SQL + LLM parse, **not MCP**; ask user if no connection) → product skill |
| Requirement clarification (generic) | `../guides/cross-layer-thinking-guide.md` | `requirement-analysis` |
| Debugging across platform layers | `../guides/cross-layer-thinking-guide.md` | `kd-debug` |
| Defensive validation and fail-fast handling | `review-checklist.md` | `defensive-programming` |
| General API contract design | `../backend/enterprise/openapi-design.md` or `../backend/cosmic-java/api-design.md` | `api-design` |
| SQL dialect reasoning | `../guides/cross-platform-thinking-guide.md` | `sql`, `mysql`, `oracle`, `postgresql`, or `sqlserver` as applicable |

`kd-grill` clarifies product line / lifecycle / events / fields for new 金蝶交付. Metadata is **not** via MCP: Agent runs readonly SQL and the model parses results. Missing host/db/credentials → ask the user. User skips DB → mark `// source=assumption`.

---

## Assistant capabilities (with kcode)

| Need | How |
| --- | --- |
| Kingdee metadata | Agent-guided readonly SQL (`sqlcmd`/`psql`) + LLM parse (`metadata-db-query.md`); ask user for connection if unknown |
| Kingdee community / API Q&A | `kd_cosmic_qa` in session (PAT required) || Product profile reminder each turn | Shown from `.trellis/spec/shared/project-context.md` |
| Product-line skill vs profile consistency | Checked when you load product skills via `/skill:` |
| Domain review before big changes | Ask assistant; use `kd-cosmic-review` skill on Cosmic projects |

---

## Conflict Rule

If loaded skills or codebase evidence conflict with the product profile written by `kcode init`, stop and ask the user to correct the initialization. Do not silently choose another product family.
