Implement a GitHub issue of nestjs-langchain end to end on the current branch - read the issue and its related history, discuss every design choice with the human and record it on the issue, write the code and its tests, try it in a sample app with a mocked model, review the diff and propose a conventional commit message. Use when the user asks to implement, work on, fix or tackle an issue (#N) or "the issue of this branch".
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Implement Issue?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/martin-bruel-implement-issue)
---
name: implement-issue
description: Implement a GitHub issue of nestjs-langchain end to end on the current branch - read the issue and its related history, discuss every design choice with the human and record it on the issue, write the code and its tests, try it in a sample app with a mocked model, review the diff and propose a conventional commit message. Use when the user asks to implement, work on, fix or tackle an issue (#N) or "the issue of this branch".
argument-hint: "[issue number]"
---
# Implement an issue
Project rules (language, code style, comments, approvals, checks) are in `CLAUDE.md`.
## 1. Identify the issue
1. The number given as argument.
2. Otherwise ask the user.
Read it entirely, with its comments:
```bash
gh issue view <N> --comments
```
Read every issue it cites (`#N`), at least their Decisions sections: RFCs (label `rfc`, e.g. #124)
hold decisions this issue depends on. To understand why existing code is the way it is:
```bash
gh issue list --state all --search "<keywords>"
git log --oneline --grep "<keyword>"
```
Summarise to the user: the goal, the acceptance criteria, the decisions already made, the
points still open, and what §4's "First, what LangChain already provides" found.
## 2. Check the branch
```bash
git branch --show-current
git status --short
```
The branch is right when it is not `main`, follows `<type>/<slug>` (`feat/`, `fix/`,
`refactor/`, `chore/`, `ci/`, `docs/`, `test/`) and matches the issue. If it is `main`, clearly
unrelated, or carries uncommitted changes that belong to something else, stop and ask the user
to switch themselves: they may have work in progress you cannot see the intent of.
If the branch already carries work (`git log main..HEAD`, `git diff main`), start from it.
## 3. Decisions: discuss, then record
Anything the issue does not settle and that shapes the public API, the behaviour, the error
messages, a dependency or the file layout is a decision for the human. For each one:
1. Check whether it is already decided (the issue, the RFC, a related issue, the existing
conventions). If so, apply it and cite the source.
2. Otherwise raise it in the conversation, not with `AskUserQuestion`: the concrete options,
their trade-offs, your recommendation. Debate it with the user until it is settled; their
counter-arguments and questions are part of the decision.
3. Record it as soon as the discussion has concluded: post the decisions settled so far as one
comment on the issue, without asking again, since the debate was the approval. Decisions
settled later in the session go in a follow-up comment. This is where the full justification
lives; the code keeps at most its shortest form, with a `see #N`:
```markdown
## Implementation decisions
**1. <Short decision>.** <Why, the alternatives set aside and why.>
**2. ...**
```
```bash
gh issue comment <N> --body-file <scratchpad>/decisions.md
```
Never cite an issue, PR, discussion or commit of another repository there (`owner/repo#N` or its
URL): GitHub shows a link back to this project on their side, and no later edit or deletion
removes it. Point to the installed code instead (`node_modules/<package>/dist/<file>:<line>`, with
the version).
A check of our own is an option only when it enforces a contract: a type, a schema or option the
developer declares, a configuration that cannot work. One that guesses the developer's intention
is set aside, or offered as something they declare ("Enforce contracts, not intentions",
`CLAUDE.md`): say so when you list the options.
Trivial details (a local name, the order of two private helpers) are not decisions: follow the
surrounding code.
## 4. Implement with the tests
Follow `CLAUDE.md` (ESM imports, no `any`, public surface, comments).
### First, what LangChain already provides
Before writing any code, library or test, search what `langchain`, `@langchain/core` and
`@langchain/langgraph` already ship for it. Do it now, not at review: once code exists, the
search turns into a justification of it. It covers test code too: a fake, a fixture, a matcher.
1. List the plan: each class, helper, fixture or mechanism you are about to write.
2. List what the installed versions export:
```bash
# every public name of `langchain`
grep -o '[A-Za-z_]*' node_modules/langchain/dist/index.d.ts | sort -u
# the entry points of @langchain/core and @langchain/langgraph
node -e "for (const p of ['@langchain/core','@langchain/langgraph']) console.log(p, Object.keys(require('./node_modules/'+p+'/package.json').exports))"
```
3. For each planned item, search those names and the `.d.ts` of the relevant entry points by
keyword: what it does (`fake`, `mock`, `testing`, `middleware`, `error`, `retry`, `usage`,
`merge`, `parse`…), not only the name you would have given it. Read the JSDoc of every hit.
4. Report the result, item by item: reused (what, where), or nothing fitting (what was searched).
A reuse that would put LangChain's types in a public signature, or depend on an internal
format, is a decision for §3 (#124's "our types, not LangChain's").
Tests (Vitest), next to what exists:
- unit: `lib/**/*.spec.ts`, colocated with the code
- integration (a real Nest module): `tests/e2e/*.spec.ts`, with the fixtures of `tests/fixtures/`
- types: `tests/types/*.test-d.ts` (`expectTypeOf`, checked by `tsc --noEmit` in `npm test`)
- models: `fakeModel()` from `@langchain/core/testing`: queued answers (`.respond()`), tool calls
(`.respondWithTools()`), errors, usage (an `AIMessage` with `usage_metadata`), several runs,
and what the model received (`.calls`). `FakeListChatModel` still fits a single answer
Every acceptance criterion is covered by a test or an explicit check. A bug fix starts with a
test that fails without the fix.
Update `README.md` when the public API or its behaviour changes (short, usage only), and the
samples when they use what changed. Then run the checks of `CLAUDE.md` until green.
## 5. Try it in a sample
Tests import `lib/`; users run `dist/` from their own app. When the change is visible to a user
(a new API, an option, an error at bootstrap, typing of the options), run it in a sample with a
mocked model: follow [references/try-in-sample.md](references/try-in-sample.md).
For changes to packaging (exports, peers, `package.json`), `npm run verify:package` is the
check: it installs the packed tarball in CommonJS and ESM consumers.
## 6. Review the change
Always a complete review, presented to the user, in two passes.
### Step back: what LangChain already does
The second pass of §4's search, on the code as written: what was added since, and what the
first pass may have missed. Put the change in perspective. The library is a thin Nest
layer over LangChain: every piece we write ourselves is code to maintain, test and explain.
For each new class, helper or mechanism of the diff:
- does `langchain` or `@langchain/core` already provide it, or something close (a callback
helper such as `BaseCallbackHandler.fromMethods`, a middleware, a tool option, a config
field, a utility)? Check the installed version in `node_modules`, not memory: read its
`.d.ts` and, when the behaviour matters, its `dist/` code
- if it does, reuse it, unless that would put LangChain's types in our public signatures or
depend on an internal format (the "our types, not LangChain's" principle of #124); say why
- does the measured LangChain behaviour still match what the issue assumed? An issue written
against an older version may claim a gap that has since closed
- could the change be smaller: fewer files, fewer layers, one path instead of two?
- does a check of the diff enforce a contract (a type, a declared schema, a configuration that
cannot work) or guess an intention? An intention: drop it, or make it something the developer
declares ("Enforce contracts, not intentions", `CLAUDE.md`)
Report each finding with the evidence (file and line in `node_modules`), and a concrete
simplification. Discuss them like the decisions of §3; apply what is agreed and record any
that changes a decision in the follow-up comment on the issue.
### Line by line
Read the full diff (`git diff main`) as a reviewer would:
- each acceptance criterion: done / tested / not done (and why)
- the decisions of §3 are all applied
- public surface: nothing exported by accident, nothing breaking unannounced
- dead code, leftover debug, TODOs, nothing left in `src/scratch/`
- comments: missing on tricky code, present on obvious code, or a justification longer than its
shortest form (shorten it, keep its `see #N`); JSDoc and README short and to the point, the
public API's JSDoc with `@param`, `@returns` and `@example`
- error messages clear and consistent with `lib/errors/messages.ts`
- README and samples in step
For a deeper pass, suggest `/code-review`. Fix what is found, rerun the checks. Drop a finding that
takes a value the types already reject (untyped JavaScript, a cast): the library does not guard its
use at runtime ("Enforce contracts, not intentions", `CLAUDE.md`). A value the types accept and that
cannot work (a `NaN` limit) stays a finding.
## 7. Propose the commit message
The `commit-msg` hook runs commitlint (`.commitlintrc.json`):
- `type(scope)?: subject`, types: `build chore ci docs feat fix perf refactor revert style test`
- subject never starts with a capital, its words keep their case (API, LangChain, `fakeModel`),
imperative, no final period, states the outcome
(e.g. `fix!: reject a tool parameter schema that contradicts its signature`)
- the pull request title becomes the commit subject on `main`: same rules, no double space, and
no final `…` (GitHub cuts a subject longer than 72 characters: restore it in full)
- the subject alone: no body, no trailer
If the change is breaking (issue labelled `breaking`, or §6 says so): `!` after the type, and a
footer saying what breaks for the consumer and how to migrate, the only addition to the subject:
```
feat!: return a `CompletedRun` from `run()` instead of a string
BREAKING CHANGE: `run()` resolves to a `CompletedRun`; read its
`output` where the string was used before.
```
Never commit or push: give the message as ready-to-run commands, which the user copies and
executes from the repository root. Stage explicit paths, never `git add -A` or `.`: list every
changed file, including new ones and the old path of a rename. Pass the message through a heredoc
so that backticks and apostrophes survive the shell:
```bash
git add <file> <file> ...
git commit -F - <<'EOF'
<type>: <subject>
EOF
```
Breaking:
```bash
git commit -F - <<'EOF'
<type>!: <subject>
BREAKING CHANGE: <what breaks and how to migrate>
EOF
```