jsii
AGENTS.md2.9k starsChanged 4 months agoApache-2.0View on GitHub
AI agent contributor guide for the aws/jsii repository.
Trending
Quiet this year.about the whole repository
Who's talking about aws/jsii
- aws/aws-cdk“‼️ NOTICE | apigateway: Unable to serialize value as `aws-cdk-lib.aws_apigateway.IModel`”GitHub · Sep 2, 2022 · 107 reactions
- hashicorp/terraform-cdk“Making cdktf dynamic”GitHub · Nov 19, 2020 · 32 reactions
- projen/projen“[WIP] feat!: migrate to constructs”GitHub · Mar 8, 2022 · 8 reactions
- aws/constructs“Constructs dependency is not supporting Node 12.x”GitHub · Jun 10, 2022 · 6 reactions
- aws/aws-cdk“fix(aws-cdk-lib): export `core` library”GitHub · Dec 13, 2021 · 6 reactions
The biggest 5 of 16 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 16
Talked about on GitHub, Hacker News and Bluesky (16 times).
On GitHub · 11
- Sep 2, 2022‼️ NOTICE | apigateway: Unable to serialize value as `aws-cdk-lib.aws_apigateway.IModel` — aws/aws-cdk107 reactions · 46 comments
- Nov 19, 2020Making cdktf dynamic — hashicorp/terraform-cdk32 reactions · 3 comments
- Mar 8, 2022[WIP] feat!: migrate to constructs — projen/projen8 reactions · 3 comments
- Jun 10, 2022Constructs dependency is not supporting Node 12.x — aws/constructs6 reactions · 6 comments
- Dec 13, 2021fix(aws-cdk-lib): export `core` library — aws/aws-cdk6 reactions · 7 comments
6 more on GitHub
- Jun 20, 2022go and azurerm out of memory with cdktf get/synth — hashicorp/terraform-cdk5 reactions · 8 comments
- Jan 6, 2022jsii 1.50.0 breaks for monorepos with local dependencies — aws/jsii-compiler5 reactions · 5 comments
- Nov 5, 2021Generating azurerm provider for go exceeds 'hard' memory limit — hashicorp/terraform-cdk5 reactions · 18 comments
- Sep 25, 2019.NET CDK developer experience improvements — aws/aws-cdk5 reactions · 2 comments
- Mar 22, 2022fix: support hoisted jsii dependencies — cdklabs/jsii-docgen4 reactions · 15 comments
- Mar 1, 2022When using Google provider + Python the import generated file get so big that the IDEs can't handle it — hashicorp/terraform-cdk4 reactions · 14 comments
On Hacker News · 3
- Jul 1, 2025Jsii – Interact with JavaScript classes in any language2 points
- Jun 20, 2023JSii allows code in any language to naturally interact with JavaScript classes2 points
- May 21, 2020AWS JSii: allows code in any lang to naturally interact with JavaScript classes1 point
On Bluesky · 2
- Jul 6, 2025JSii: invoke TypeScript code from Python, Go, Java, C#, etc. github.com/aws/jsii #ECMAScript #JavaScript — @ecmascript.news1 likes and repost
- Mar 29, 2021Side-note: CDK is written in TypeScript but supports other languages. Thanks to jsii which allows #TypeScript to be consumed by other… — @trivikram.bsky.social0 likes and reposts · 1 reply
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
10 rules. About 0 are common, 1 is distinctive, and 9 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 96
Test fixtures (jsii-calc, @scope/*) are shared with the separate aws/jsii-compiler repository (which has its own copy under fixtures/)
- Very specific: line 111
All requests carry an api discriminator field.
- Very specific: line 193
Read .jsii assembly from the compiled npm package
- Very specific: line 219
After modifying a target, run cd packages/jsii-pacmak && yarn test:update to update generated code snapshots.
- Very specific: line 236
After modifying test fixtures, run yarn test:update in at least jsii-pacmak and jsii-reflect to update snapshots.
- Distinctive: line 245
If you add a test and don't regenerate the report, the build will also fail.
- Very specific: line 259
If compliance tests change, regenerate the compliance report (yarn compliance) and commit the updated …
- Very specific: line 266
MUST NOT: add compliance tests to a language binding without adding them to the suite definition in tools/jsii-compliance/suite.ts
- Very specific: line 268
MUST NOT: use type unions when avoidable — they degrade to Object/any in static languages
- Very specific: line 272
MUST NOT: add circular dependencies between submodules — Lerna rejects cycles (rejectCycles: true)
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
AI agent contributor guide for the aws/jsii repository.
Overview
- jsii enables TypeScript libraries to be consumed naturally in Python, Java, C#/.NET, and Go — users write idiomatic code in their language while jsii handles cross-language interop.
- Key packages in this monorepo:
packages/@jsii/kernel— Node.js process managing JS objects on behalf of host runtimespackages/@jsii/runtime— Webpack-bundled runtime bootstrappackages/@jsii/spec— Assembly schema definition (.jsiiformat)packages/@jsii/python-runtime— Python host runtimepackages/@jsii/java-runtime— Java host runtimepackages/@jsii/dotnet-runtime— .NET host runtimepackages/@jsii/go-runtime— Go host runtimepackages/jsii-pacmak— Code generator producing language-specific packages from.jsiiassembliespackages/jsii-reflect— TypeScript reflection library for.jsiiassembliespackages/jsii-diff— API compatibility checkerpackages/codemaker— Code generation utilities (indentation, file management)packages/jsii-calc,packages/@scope/*— Test fixtures exercising the full type systemtools/jsii-compliance— Compliance suite and reporting toolingtools/jsii-build-tools— Internal build utilities
- Compiler and rosetta live in separate repositories:
- jsii compiler → https://github.com/aws/jsii-compiler
- jsii-rosetta (transliteration) → https://github.com/aws/jsii-rosetta
- Monorepo tooling: Yarn 4 workspaces (
packageManager: yarn@4.13.0) + Lerna for build orchestration - Design tenets:
- APIs must feel idiomatic in all target languages
- Applications behave identically regardless of language (correctness over performance)
- jsii does not attempt to support all TypeScript idioms — only those representable across all targets
- Produced artifacts are compatible with each language's idiomatic package management tools
Contributor Principles
- Backwards compatibility of the jsii assembly format and kernel API is critical — never break existing consumers.
- Cross-language correctness must be verified — a change affecting one language target must be validated against all targets.
- Generated code must be idiomatic in each target language — follow each language's conventions and patterns.
- The jsii type system restrictions exist to ensure cross-language representability — do not relax them without careful consideration and validation across all targets.
- Snapshot tests must be updated when generated code changes — run
yarn test:updateto refresh snapshots.
Quick Reference Commands
| Command | Description | Scope |
yarn install && yarn build | Full bootstrap and build | Repo root |
cd packages/X && yarn build | Build single package | Package dir |
yarn test | Full test suite (includes compliance) | Repo root |
cd packages/X && yarn test | Test single package | Package dir |
yarn test:update | Update all snapshots | Repo root |
cd packages/X && yarn test:update | Update package snapshots | Package dir |
yarn lint | Lint all packages | Repo root |
yarn lint:fix | Auto-fix lint issues | Repo root |
yarn compliance | Generate compliance report | Repo root |
yarn upgrade:jsii | Upgrade jsii/rosetta versions | Repo root |
Notes:
- Builds use
--concurrency=1due to inter-package dependencies. - Monorepo uses Yarn 4 workspaces + Lerna orchestration.
- For individual packages, use
cd packages/X && yarn <script>(e.g.,cd packages/@jsii/kernel && yarn test).
Codebase Layout
Packages
| Path | Purpose |
packages/@jsii/kernel | The JavaScript kernel — manages objects and executes code |
packages/@jsii/runtime | IPC wrapper around kernel (webpack-bundled for distribution) |
packages/@jsii/spec | Assembly schema definition and validation |
packages/@jsii/check-node | Node.js version compatibility checks |
packages/@jsii/python-runtime | Python host runtime library |
packages/@jsii/java-runtime | Java host runtime library |
packages/@jsii/dotnet-runtime | .NET host runtime library |
packages/@jsii/go-runtime | Go host runtime library |
packages/jsii-pacmak | Code generator (targets: Python, Java, .NET, Go, JS) |
packages/jsii-reflect | Strongly-typed reflection library for .jsii assemblies |
packages/jsii-diff | API backwards compatibility checker |
packages/jsii-config | Interactive jsii configuration tool (experimental) |
packages/codemaker | Code generation utilities (indentation, file management) |
packages/jsii-calc | Test fixture library exercising the full type system |
packages/@scope/* | Additional test fixture packages (base, lib, base-of-base) |
tools/jsii-compliance | Compliance suite definition and report generation |
tools/jsii-build-tools | Internal build utilities |
Code Generation Targets
- Targets live in
packages/jsii-pacmak/lib/targets/ - One file per language:
python.ts,java.ts,dotnet.ts,go.ts,js.ts - Complex targets have subdirectories:
dotnet/,go/,python/
Specifications & Docs
- Specification documents:
gh-pages/content/specification/ - Architecture reference:
docs/jsii-architecture-reference.md - Test fixtures (
jsii-calc,@scope/*) are shared with the separateaws/jsii-compilerrepository (which has its own copy underfixtures/)
Architecture
Two-Process Model
The host process (JVM, .NET CLR, CPython, Go runtime) communicates with a kernel process (Node.js) via JSON-encoded messages over STDIN/STDOUT pipes. The host never executes JavaScript directly — all JS execution happens in the kernel.
Host Process (Python/Java/.NET/Go) ←→ Kernel Process (Node.js)
STDIN/STDOUT JSON IPCKernel API
All requests carry an api discriminator field. The kernel supports 15 message types:
| API | Purpose |
load | Load a jsii assembly (npm tarball) into the kernel |
naming | Get language-specific naming configuration |
stats | Get kernel statistics (object count) |
create | Instantiate an object |
del | Destroy an object reference (free memory) |
invoke | Call an instance method |
sinvoke | Call a static method |
get | Read an instance property |
sget | Read a static property |
set | Write an instance property |
sset | Write a static property |
begin | Start an async method invocation |
end | Await an async method's result |
callbacks | List outstanding callback requests |
complete | Fulfill a callback request |
Callback Mechanism
When JavaScript code calls a method or property that was overridden in the host language, the kernel sends a callback request instead of a normal response. The host must: (1) execute the overridden method, (2) send a complete response with the result, (3) receive the original call's actual response. Callback types include InvokeCallback, GetCallback, and SetCallback.
Serialization
| Type | Passing | Wire Format |
| Primitives (bool, number, string) | By value | JSON identity |
| Enums | By value | {"$jsii.enum": "fqn/ENTRY"} |
| Dates | By value | {"$jsii.date": "ISO-8601"} |
| Lists | By value | JSON array |
| Maps | By value | {"$jsii.map": {...}} |
| Structs | By value | {"$jsii.struct": {"fqn": "...", "data": {...}}} |
| Class instances | By reference | {"$jsii.byref": "FQN@ID"} |
Dual-Node Process
The @jsii/runtime spawns two node processes: a wrapper process manages IPC with the host via STDIN/STDOUT, while a core process runs the actual kernel communicating with the wrapper via FD#3. This separation exists because Java and C# cannot spawn child processes with additional open file descriptors.
Debugging
| Variable | Purpose |
JSII_DEBUG=1 | Verbose IPC tracing to STDERR |
JSII_DEBUG_TIMING=1 | Kernel API timing information |
JSII_RUNTIME | Override path to jsii-runtime (use local non-bundled version) |
NODE_OPTIONS | Configure node runtime (e.g., --inspect-brk for debugger) |
Type System
Type Mappings
| jsii Type | TypeScript Source | Notes |
| Boolean | boolean | Primitive |
| Number | number | All floating point |
| String | string | UTF-8 |
| List | Array<T>, T[] | Passed by-value (copied across boundary) |
| Map | { [key: string]: T } | Passed by-value |
| Enum | enum | Cannot be downcast to value type |
| Any | any, unknown | Opaque, implicitly nullable |
| Void | void | No return value |
| Date | Date | Special JSON serialization |
| Class | class | Passed by-reference |
| Interface (behavioral) | interface IFoo | Prefixed with I |
| Struct | interface Foo | No I prefix, all readonly, no methods |
| Promise | Promise<T> | Only as method return type |
Restrictions
- Unsupported types: tuples,
never,bigint,symbol - Struct vs Interface: interfaces prefixed with
Iare behavioral; without prefix they are structs (all propertiesreadonly, no methods). Structs cannot extend behavioral interfaces and vice versa. - No method overloads — TypeScript overloads are not supported in the jsii type system
- Liskov substitution — overridden methods must retain the exact same type signature (no covariant returns, no contravariant parameters)
- Type unions — result in
Object/anyin statically typed languages; avoid when possible - Scope — restrictions only apply to declarations exported from the module's main entry point; internal code is unrestricted
Code Generation
Pipeline
- Read
.jsiiassembly from the compiled npm package - Generate idiomatic source code for the target language
- Compile the generated source (language-specific toolchain)
- Package into publishable artifacts (wheel, JAR, NuGet, Go module)
Targets
| File | Language | Output |
python.ts | Python | PyPI wheels (.whl) |
java.ts | Java | Maven JARs |
dotnet.ts + dotnet/ | C# (.NET) | NuGet packages (.nupkg) |
go.ts + go/ | Go | Go module source |
js.ts | JavaScript | npm package (passthrough) |
Notes:
- Generated packages bundle the original JavaScript (npm tarball) inside the language-specific package.
- Each generated package depends on the language's host runtime library (
@jsii/*-runtime). - The
.jsiiassembly is included in the generated package for downstream consumers. - The
codemakerpackage (packages/codemaker) provides code generation utilities (indentation management, file creation, code blocks) used by all targets.
Modifying a Target
- The Python target (
packages/jsii-pacmak/lib/targets/python.ts) is the recommended reference implementation to study when modifying or adding a code generation target. - Each target extends a base class and implements visitor methods that traverse the assembly's type system.
- After modifying a target, run
cd packages/jsii-pacmak && yarn test:updateto update generated code snapshots. - For changes to the Python target that affect import behavior, lazy loading, or runtime type checking, follow the verification checklist in
docs/target-python/import-verification.md.
Testing
Testing Layers
| Layer | Tool | Purpose |
| Unit tests | Jest | Package-level logic verification |
| Snapshot tests | Jest snapshots | Generated code regression detection |
| Compliance suite | Custom framework | Cross-language behavioral consistency |
Test Fixtures
jsii-calcand@scope/*packages serve as test fixtures exercising the full jsii type system (classes, interfaces, structs, enums, collections, async, overrides, etc.).- These fixtures are compiled with the jsii compiler and used by
jsii-pacmak,jsii-reflect, and the runtime test suites. - After modifying test fixtures, run
yarn test:updatein at leastjsii-pacmakandjsii-reflectto update snapshots. - The
aws/jsii-compilerrepository maintains its own copy of these fixtures underfixtures/.
Compliance Suite
- Abstract test cases defined in
tools/jsii-compliance/suite.ts. - Each language binding must implement the test cases individually.
- Report generated via
yarn compliance(orcd tools/jsii-compliance && yarn report). - Adding a compliance test to a language binding without adding it to the suite definition will cause the build to fail.
- If you add a test and don't regenerate the report, the build will also fail.
- Report file:
gh-pages/content/specification/6-compliance-report.md(checked into source control). - Report statuses:
- 🟢 — Test passes for this language
- ⚪ — Test is not applicable for this language
- ⭕ — Test is not implemented (yet) for this language
- 🔴 — Test is failing for this language
PR Conventions
- PR titles follow conventional commit format:
type[(scope)]: description- Allowed types:
feat,fix,chore,docs,style,refactor,perf,test,build,ci,revert
- Allowed types:
- Scope is optional — use the package name when the change is scoped to a single package (e.g.,
fix(jsii-pacmak): ...). - PR body must confirm contribution under the Apache 2.0 license (by submitting, you agree to the Developer Certificate of Origin).
- If compliance tests change, regenerate the compliance report (
yarn compliance) and commit the updatedgh-pages/content/specification/6-compliance-report.md.
Anti-Patterns
- MUST NOT relax jsii type system restrictions without cross-language validation across all targets
- MUST NOT modify the kernel API protocol without updating all host runtime libraries (Python, Java, .NET, Go)
- MUST NOT change generated code patterns without updating snapshots (
yarn test:update) - MUST NOT add compliance tests to a language binding without adding them to the suite definition in
tools/jsii-compliance/suite.ts - MUST NOT introduce method overloads in test fixtures — they are not representable in the jsii type system
- MUST NOT use type unions when avoidable — they degrade to
Object/anyin static languages - MUST NOT assume thread safety in runtime libraries — they are single-threaded by design
- MUST NOT modify
@jsii/runtimebundled code directly — it is webpack-bundled; edit the source and rebuild - MUST NOT break the
$jsii.*serialization wire format without coordinating changes across all host runtimes simultaneously - MUST NOT add circular dependencies between submodules — Lerna rejects cycles (
rejectCycles: true)
Key References
| Resource | Location |
| Type system specification | gh-pages/content/specification/2-type-system.md |
| Kernel API specification | gh-pages/content/specification/3-kernel-api.md |
| Compliance suite specification | gh-pages/content/specification/4-standard-compliance-suite.md |
| Architecture reference | docs/jsii-architecture-reference.md |
| Python import/lazy-loading verification checklist | docs/target-python/import-verification.md |
| jsii compiler repository | https://github.com/aws/jsii-compiler |
| jsii-rosetta repository | https://github.com/aws/jsii-rosetta |
| jsii-superchain repository | https://github.com/aws/jsii-superchain |
| Published documentation | https://aws.github.io/jsii/ |
| Contributing guide | CONTRIBUTING.md |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

