> For the complete documentation index, see [llms.txt](https://clarity-7.gitbook.io/clarity-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://clarity-7.gitbook.io/clarity-docs/clarity-moniversive-invariant-static-mis/learn/langchain-prompt-engineering.md).

# LangChain + MIS

> Generated 2026-07-29T03:15:30Z · combine LLM chains with **indexed `.mis`** surfaces

## Workflow

1. **Retrieve** — load `mis_code_index.json` or call `clrty_getMisCodeIndex` (filter by `kind`, `path`, `band`).
2. **Constrain** — system prompt: author **`.mis` only** · **`bin/misc`** · letter-hash · taxonomy branch from `mis_framework_taxonomy.json`.
3. **Generate** — emit `module` / `outcome` / `invariant`; prefer `mis.select` over nested `if`.
4. **Verify** — `bin/misc path.mis --check --compact-letters` · `make mis-ml-check`.
5. **Register** — append index entry · `make gitbook-moniversive-build` · optional `make gitbook-publish`.

## LangChain-style composition (conceptual)

| Step                 | MIS-native analogue                                                                                                                                                                                                  |
| -------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Document loader      | Parse `mis_code_index` + [static ML bands](/clarity-docs/clarity-moniversive-invariant-static-mis/catalog-generated/static-ml-invariant-bands.md)                                                                    |
| Retriever            | Taxonomy route (`MisRouter.mis`) · pack id (776–875, 876–975, …)                                                                                                                                                     |
| Prompt template      | [ai-prompting.md](/clarity-docs/clarity-moniversive-invariant-static-mis/learn/ai-prompting.md) + [prompt-mlx-routing.md](/clarity-docs/clarity-moniversive-invariant-static-mis/mis-taxonomy/prompt-mlx-routing.md) |
| Tool / function call | `outcome` name from catalog · check with `bin/misc`                                                                                                                                                                  |
| Output parser        | Letter-hash + invariant syntax validation (compiler)                                                                                                                                                                 |

## Example prompt shell

```
You write Moniversive Invariant Static (.mis) for clrty-1/1202.
Resolve symbols via mis_code_index.json first.
Target band: 876-975 architecture primitive {name}.
Emit module + letter_hash_bound invariant + outcomes only.
No Python app code. No legacy Solidity. Verify: bin/misc {path} --check --compact-letters
```

## Host Python (bootstrap only)

Orchestration scripts under `scripts/mis-ml/` may call LangChain **only** to drive codegen; shipped logic remains **`.mis`**. See [py-to-mis.md](/clarity-docs/clarity-moniversive-invariant-static-mis/migration-replaces-python-solidity/py-to-mis.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://clarity-7.gitbook.io/clarity-docs/clarity-moniversive-invariant-static-mis/learn/langchain-prompt-engineering.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
