Skip to content

Commit b8e5516

Browse files
shixishcursoragent
andcommitted
docs: document LangChain 1.x import rules and parallel doc maintenance
Expand sync-langchain-docs to cover all six doc surfaces, drop README-as- source-of-truth wording, and record which imports use langchain vs langchain_core. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 76c6f34 commit b8e5516

7 files changed

Lines changed: 83 additions & 35 deletions

File tree

.claude/skills/audit-langchain-docs/SKILL.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ allowed-tools: Bash(python3:*), Bash(grep:*), Bash(find:*), Bash(make:*), Read,
88

99
This skill checks every Diffbot documentation file on the LangChain docs site against this repo's public API, runs the docs repo's own validators (Vale, etc.), and propagates any findings back into this repo — `README.md` and Python source files (docstrings, comments). The docs repo's validation standards apply repo-wide here.
1010

11-
## Source of truth (this repo)
11+
## Package authority (this repo)
1212

1313
| Artifact | What it defines |
1414
|----------|----------------|
@@ -17,17 +17,19 @@ This skill checks every Diffbot documentation file on the LangChain docs site ag
1717
| `langchain_diffbot/retrievers/` | Retriever constructor parameters, return types |
1818
| `langchain_diffbot/chat_models/` | Chat model constructor parameters |
1919
| `langchain_diffbot/document_loaders/` | Loader constructor parameters |
20-
| `README.md` | Canonical prose, API table, auth model, examples |
20+
| `README.md` | GitHub/PyPI package reference — prose, API table, auth model, examples |
2121

2222
## Documentation files to audit (langchain-ai/docs)
2323

2424
A local `langchain-ai/docs` checkout is expected at the sibling **`../langchain-docs`** by default (override with `$LANGCHAIN_DOCS_REPO`).
2525

2626
| File | What it should reflect |
2727
|------|----------------------|
28-
| `src/oss/python/integrations/providers/diffbot.mdx` | Overview hub: API table, install, auth, component table, links to tools/retrievers pages |
28+
| `src/oss/python/integrations/providers/diffbot.mdx` | Overview hub: API table, install, auth, component table, links to detail pages |
2929
| `src/oss/python/integrations/tools/diffbot.mdx` | All 7 tools: `DiffbotExtractTool`, `DiffbotWebSearchTool`, `DiffbotKnowledgeGraphTool`, `DiffbotEntitiesTool`, `DiffbotAskTool`, `DiffbotOntologyTool`, `DiffbotDQLProbeTool` |
3030
| `src/oss/python/integrations/retrievers/diffbot.mdx` | Both retrievers: `DiffbotKnowledgeGraphRetriever`, `DiffbotWebSearchRetriever` |
31+
| `src/oss/python/integrations/chat/diffbot.mdx` | `ChatDiffbot` usage |
32+
| `src/oss/python/integrations/document_loaders/diffbot.mdx` | `DiffbotExtractLoader`, `DiffbotCrawlLoader` |
3133
| `src/oss/python/integrations/providers/all_providers.mdx` | Card entry for Diffbot |
3234
| `src/oss/python/integrations/tools/index.mdx` | Row in Search table + card in All tools and toolkits |
3335
| `src/oss/python/integrations/retrievers/index.mdx` | Rows in External index table + card in All retrievers |
@@ -165,5 +167,6 @@ uv run pytest tests/unit_tests/test_readme_parity.py tests/unit_tests/test_readm
165167
## Notes
166168

167169
- Fixes to `README.md` and Python source are applied directly by this skill. Fixes to `langchain-docs` files must be made there separately (this repo has no write access to the remote).
168-
- To sync the provider hub after fixing README.md: run `/sync-langchain-docs`.
169-
- To fix tools/retrievers deep-dive pages: edit them directly in `langchain-ai/docs`.
170+
- To align langchain-docs pages with README.md after fixes here: run `/sync-langchain-docs`.
171+
- To fix detail pages: edit them directly in `langchain-ai/docs`.
172+
- **LangChain 1.x imports:** Flag `langchain.documents`, `langchain.prompts`, `langchain.runnables`, or `langchain.output_parsers` as stale — those modules do not exist. Use `langchain.messages` for message types and `langchain_core` for `Document`, prompts, parsers, and runnables. See the `sync-langchain-docs` skill for the full table.

.claude/skills/sync-langchain-docs/SKILL.md

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,51 @@
11
---
22
name: sync-langchain-docs
3-
description: "Keep all Diffbot docs in sync: README.md in this repo and the three LangChain docs pages (providers, tools, retrievers). Use when code changes, when any doc page drifts, or when the user says: sync langchain docs, update the diffbot docs, sync the integration pages."
3+
description: "Keep all Diffbot docs in sync: README.md in this repo and the LangChain docs pages (providers, tools, retrievers, chat, document loaders). Use when code changes, when any doc page drifts, or when the user says: sync langchain docs, update the diffbot docs, sync the integration pages."
44
allowed-tools: Bash(python3:*), Bash(git:*), Bash(gh:*), Bash(make:*), Read, Edit, Write
55
---
66

77
# Sync Diffbot docs across all pages
88

99
## What this skill does
1010

11-
Four documents describe the `langchain-diffbot` package. Keep them all accurate and consistent — update whichever ones need it, not just one.
11+
Six documents describe the `langchain-diffbot` package. Keep them all accurate and consistent — update whichever ones need it, not just one.
1212

1313
| File | Audience | Owns |
1414
|------|----------|------|
1515
| `README.md` (this repo) | GitHub / PyPI readers | Complete package reference — install, auth, all classes, examples |
1616
| `providers/diffbot.mdx` (langchain-docs) | Docs site visitors landing on Diffbot | Overview only: install, auth, components table, links to detail pages |
1717
| `tools/diffbot.mdx` (langchain-docs) | Docs site visitors looking for tools | Full tool documentation with examples |
1818
| `retrievers/diffbot.mdx` (langchain-docs) | Docs site visitors looking for retrievers | Full retriever documentation with examples |
19+
| `chat/diffbot.mdx` (langchain-docs) | Docs site visitors looking for chat models | `ChatDiffbot` instantiation, invocation, streaming, chaining |
20+
| `document_loaders/diffbot.mdx` (langchain-docs) | Docs site visitors looking for loaders | `DiffbotExtractLoader`, `DiffbotCrawlLoader` |
1921

20-
**Link, don't duplicate within langchain-docs.** The provider hub names every class and links to the tools/retrievers pages; the detail pages don't repeat install/auth. The README is for a different audience and channel (GitHub/PyPI) — it can be complete without violating this rule.
22+
**Link, don't duplicate within langchain-docs.** The provider hub names every class and links to detail pages; detail pages don't repeat install/auth. The README is for a different audience and channel (GitHub/PyPI) — it can be complete without violating this rule.
23+
24+
## LangChain import rules (LangChain 1.x)
25+
26+
Assume readers use current `langchain` and `langchain-core` releases. The slim `langchain` package (1.3+) only ships `agents`, `chat_models`, `embeddings`, `messages`, `rate_limiters`, and `tools`. Paths like `langchain.documents` or `langchain.prompts` do not exist and will fail if copied.
27+
28+
Use this split in **every** README and MDX example:
29+
30+
| Symbol | Import from |
31+
|--------|-------------|
32+
| `HumanMessage`, `AIMessage`, `ToolMessage`, other message types | `langchain.messages` |
33+
| `create_agent`, `tool`, `init_chat_model`, agent middleware | `langchain.agents`, `langchain.tools`, `langchain.chat_models` |
34+
| `Document`, `ChatPromptTemplate`, `StrOutputParser`, `RunnablePassthrough`, LCEL primitives | `langchain_core.*` |
35+
36+
Examples:
37+
38+
```python
39+
from langchain.messages import HumanMessage
40+
from langchain_core.documents import Document
41+
from langchain_core.prompts import ChatPromptTemplate
42+
from langchain_core.output_parsers import StrOutputParser
43+
from langchain_core.runnables import RunnablePassthrough
44+
```
45+
46+
**Docs CI note:** The langchain-docs **Check PR Imports** job only flags `langchain_core` imports that `langchain` actually re-exports (mostly `messages` and `tools`). `langchain_core.documents` and `langchain_core.prompts` are allowed and correct — do not "fix" them to nonexistent `langchain.*` paths.
47+
48+
**Package source code** (`langchain_diffbot/*.py`) continues to import from `langchain_core` directly; these rules apply to user-facing documentation and examples only.
2149

2250
## Where the docs repo lives
2351

@@ -33,20 +61,22 @@ If that errors, ask the user for its path or to clone `git@github.com:langchain-
3361

3462
<Steps>
3563

36-
### Read all four files
64+
### Read all six files
3765

3866
Read every file before touching any of them:
3967

4068
- `README.md`
4169
- `$(python3 .claude/skills/sync-langchain-docs/sync.py --repo)/src/oss/python/integrations/providers/diffbot.mdx`
4270
- `$(python3 .claude/skills/sync-langchain-docs/sync.py --repo)/src/oss/python/integrations/tools/diffbot.mdx`
4371
- `$(python3 .claude/skills/sync-langchain-docs/sync.py --repo)/src/oss/python/integrations/retrievers/diffbot.mdx`
72+
- `$(python3 .claude/skills/sync-langchain-docs/sync.py --repo)/src/oss/python/integrations/chat/diffbot.mdx`
73+
- `$(python3 .claude/skills/sync-langchain-docs/sync.py --repo)/src/oss/python/integrations/document_loaders/diffbot.mdx`
4474

4575
Also check what triggered the sync — git diff, the user's description, or a specific change — so you know what actually changed and can limit edits to what's necessary.
4676

4777
### Identify what needs updating
4878

49-
For each of the four files, decide independently whether it needs a change. Common triggers:
79+
For each file, decide independently whether it needs a change. Common triggers:
5080

5181
- **New or renamed class** → update the components table in README + provider hub; add documentation to the appropriate detail page (tools or retrievers); update any import examples.
5282
- **Behavior change to a tool or retriever** → update README + the matching detail page.
@@ -69,7 +99,7 @@ uv run pytest tests/unit_tests/test_readme_parity.py tests/unit_tests/test_readm
6999

70100
**providers/diffbot.mdx** — hub only. Structure:
71101
1. Frontmatter (`title`, `description`)
72-
2. Sync comment (keep it — see current file for wording)
102+
2. Maintenance comment (keep it — see current file for wording; README and MDX pages are peers, not source/derived)
73103
3. Short intro + API → class mapping table
74104
4. `## Installation` as `<CodeGroup>` with `pip` and `uv` tabs
75105
5. `## Authentication` — prose + `db = Diffbot(...)` snippet only; no usage examples
@@ -80,12 +110,27 @@ uv run pytest tests/unit_tests/test_readme_parity.py tests/unit_tests/test_readm
80110

81111
**retrievers/diffbot.mdx** — full retriever docs. Include both retriever classes, output shaping, LCEL chain usage. Link back to the provider hub for install/auth. Do not repeat tool content.
82112

113+
**chat/diffbot.mdx**`ChatDiffbot` only. Instantiation, invocation, streaming, chaining. Follow the LangChain import rules above (`langchain.messages`, `langchain_core.prompts`).
114+
115+
**document_loaders/diffbot.mdx**`DiffbotExtractLoader` and `DiffbotCrawlLoader` only. Link back to the provider hub for install/auth.
116+
83117
MDX formatting rules (Vale enforces these — violations block the docs CI):
84118
- Em dashes: no surrounding spaces (`word—word`, not `word — word`)
85119
- `prebuilt` not `pre-built`
86120
- Install blocks: `<CodeGroup>` with `pip` and `uv` tabs
87121
- Relative links to this repo become absolute `https://github.com/diffbot/langchain-diffbot/...` URLs
88122

123+
### Validate imports and prose in langchain-docs
124+
125+
If you changed any MDX in the docs repo, run the import checker (flags only `langchain_core` imports that should be `langchain.*` re-exports) and Vale:
126+
127+
```bash
128+
DOCS="$(python3 .claude/skills/sync-langchain-docs/sync.py --repo)"
129+
cd "$DOCS"
130+
uv run scripts/check_pr_imports.py
131+
make lint_prose FILES="<space-separated changed .mdx paths>"
132+
```
133+
89134
### Lint every changed MDX file
90135

91136
The docs repo has its own Vale setup. Run it against each changed MDX:

.claude/skills/sync-langchain-docs/sync.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
#!/usr/bin/env python3
2-
"""Resolve the Diffbot provider page inside a local langchain-ai/docs checkout.
2+
"""Resolve Diffbot docs paths inside a local langchain-ai/docs checkout.
33
4-
README.md in this repo is the single source of truth for the Diffbot provider
5-
page on the LangChain docs site; the `sync-langchain-docs` skill *generates* the
6-
page (`.mdx`) from it. The generation itself is agent-driven (prose → house
7-
style), so this script does not copy anything — it just resolves where the page
8-
lives, so the skill never hardcodes the path:
4+
README.md and the LangChain docs pages are maintained in parallel—not generated
5+
from one another. Import rules for examples (LangChain 1.x) live in
6+
`.claude/skills/sync-langchain-docs/SKILL.md`. This script only resolves where
7+
those pages live so the skill never hardcodes paths:
98
109
# Resolve the docs repo from --docs-repo, $LANGCHAIN_DOCS_REPO, or the
1110
# sibling ../langchain-docs, then print:

CLAUDE.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,21 @@ Methods like `crawl_list_jobs`, `crawl_get_job`, `crawl_delete_job`, and `dql_re
5353

5454
## Documentation
5555

56-
Four documents describe this package; keep them all accurate when things change:
56+
Six documents describe this package; keep them all accurate when things change:
5757

5858
| File | Audience | Owns |
5959
|------|----------|------|
6060
| `README.md` | GitHub / PyPI readers | Complete reference — install, auth, all classes, examples |
6161
| `providers/diffbot.mdx` (langchain-docs) | Docs site — Diffbot landing page | Overview only: install, auth, components table, links to detail pages |
6262
| `tools/diffbot.mdx` (langchain-docs) | Docs site — tools reference | Full tool documentation with examples |
6363
| `retrievers/diffbot.mdx` (langchain-docs) | Docs site — retrievers reference | Full retriever documentation with examples |
64+
| `chat/diffbot.mdx` (langchain-docs) | Docs site — chat model reference | `ChatDiffbot` usage |
65+
| `document_loaders/diffbot.mdx` (langchain-docs) | Docs site — loader reference | Extract and crawl loaders |
6466

6567
The langchain-docs pages link to each other rather than duplicate content. Use the `sync-langchain-docs` skill to update whichever pages need it. The local docs checkout is expected at sibling `../langchain-docs` (overridable via `$LANGCHAIN_DOCS_REPO`).
6668

69+
**LangChain 1.x imports in docs:** Use `langchain.messages` for message types; use `langchain_core` for `Document`, prompts, output parsers, and runnables. Do not use `langchain.documents` or `langchain.prompts` — those modules do not exist in current `langchain` releases. See the `sync-langchain-docs` skill for the full table and CI notes.
70+
6771
**The docs repo leads on prose quality.** If validation fixes are made to the docs pages (Vale, CI, editorial review), propagate those improvements back to `README.md` — don't let the README drift to a lower standard.
6872

6973
Two unit suites keep the README in lockstep with the package: `tests/unit_tests/test_readme_parity.py` (the `## Components reference` table matches `__all__`, every class is documented, every example builds a client) and `tests/unit_tests/test_readme_examples.py` (every executable example runs under `respx` mocks; the crawl example is documented but not executed — flagged via `tests/readme.py`'s `is_executable`). `tests/integration_tests/test_readme_examples.py` runs the same blocks live.

tests/readme.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Shared helpers for testing the python code blocks in README.md.
22
3-
README.md is the single source of truth for this package's docs: the LangChain
4-
provider page is *generated from it* by the `sync-langchain-docs` skill. Three
5-
suites consume these helpers: `unit_tests/test_readme_examples.py` runs the
6-
blocks against respx mocks (deterministic, no token),
7-
`integration_tests/test_readme_examples.py` runs them against the live Diffbot
8-
API, and `unit_tests/test_readme_parity.py` checks the page stays in lockstep
9-
with the package surface (`__all__`). The execution suites decide which blocks
3+
README.md is maintained alongside the LangChain docs pages (provider hub, tools,
4+
retrievers, chat). Three suites consume these helpers:
5+
`unit_tests/test_readme_examples.py` runs the blocks against respx mocks
6+
(deterministic, no token), `integration_tests/test_readme_examples.py` runs them
7+
against the live Diffbot API, and `unit_tests/test_readme_parity.py` checks the
8+
README components table stays in lockstep with the package surface (`__all__`).
9+
The execution suites decide which blocks
1010
to run by inspecting each block's imports and whether it is executable.
1111
"""
1212

tests/unit_tests/test_readme_examples.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
"""Execute the Python code blocks in README.md against mocked Diffbot endpoints.
22
3-
README.md is the single source of truth for this package's docs: the
4-
docs.langchain.com provider page is *generated from it* by the
5-
`sync-langchain-docs` skill. This guards against the README (and therefore that
6-
page) drifting from the package: a renamed class, a changed kwarg, or a wrong
7-
import surfaces here as a failing exec rather than as a user copy-pasting a
8-
broken snippet.
3+
README.md is maintained alongside the LangChain docs pages. This guards against
4+
the README drifting from the package: a renamed class, a changed kwarg, or a
5+
wrong import surfaces here as a failing exec rather than as a user copy-pasting
6+
a broken snippet.
97
108
The blocks are run under `respx` mocks of every Diffbot endpoint — the same
119
canned-response style the rest of `unit_tests/` uses — so the suite stays

tests/unit_tests/test_readme_parity.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"""Keep README.md in lockstep with the package surface.
22
3-
README.md is the single source of truth for this package's docs; the LangChain
4-
provider page is generated from it by the `sync-langchain-docs` skill. These
5-
tests fail if the README drifts from `__all__`, so a class added, renamed, or
6-
removed cannot silently miss the docs (and therefore the published page).
3+
README.md is maintained alongside the LangChain docs pages. These tests fail if
4+
the README drifts from `__all__`, so a class added, renamed, or removed cannot
5+
silently miss the README components table.
76
"""
87

98
from __future__ import annotations

0 commit comments

Comments
 (0)