facebook/sapling/creating-endpoints
Claude Code and agent skill by facebook/sapling
- community
Checking that the SKILL.md file is still in the repository.
This guide explains how to create new EdenAPI/SLAPI endpoints, covering both streaming and non-streaming patterns.
Install
npx vskill@latest install facebook/sapling/creating-endpointsSKILL.md
The same SKILL.md was published earlier as facebook/sapling/creating-endpoints.
Creating EdenAPI Endpoints
This guide explains how to create new EdenAPI/SLAPI endpoints, covering both streaming and non-streaming patterns.
Overview
EdenAPI is a REST-like API that connects Sapling clients to the Mononoke server. Creating a new endpoint involves three main steps:
- Define Types - Request and response types in
edenapi_types - Server Handler - Implement the handler in
slapi_service - Client Implementation - Add client-side code (lands after server)
Key Files Reference
| Component | Location | |
|---|---|---|
| Types | fbcode/eden/scm/lib/edenapi/types/src/ | |
| Server Handler Trait | fbcode/eden/mononoke/servers/slapi/slapi_service/src/handlers/handler.rs | |
| Server Handlers | fbcode/eden/mononoke/servers/slapi/slapi_service/src/handlers/*.rs | |
| Router Registration | fbcode/eden/mononoke/servers/slapi/slapi_service/src/handlers.rs | |
| Client API Trait | fbcode/eden/scm/lib/edenapi/trait/src/api.rs | |
| Client Implementation | fbcode/eden/scm/lib/edenapi/src/client.rs |
Step 1: Define Request/Response Types
Location: fbcode/eden/scm/lib/edenapi/types/src/
Types need the #[auto_wire] macro to generate wire format serialization and the ToWire trait implementation. All parameters should be sent in the request body, not in the URL path.
Required Attributes
Key points:
#[auto_wire]generates wire format code#[id(N)]assigns a stable field ID for serialization (use sequential numbers)- Include
Serialize,Deserializefor serde support Arbitraryderive enables property-based testing- All parameters go in the request struct, not in URL path
Non-streaming Example
See EphemeralPrepareRequest/EphemeralPrepareResponse in types/src/commit.rs:555-570:
Streaming Example
See CommitMutationsRequest/CommitMutationsResponse in types/src/commit.rs:609-623:
Step 2: Create Server-Side Handler
Location: fbcode/eden/mononoke/servers/slapi/slapi_service/src/handlers/
2a. Add Method to SaplingRemoteApiMethod Enum
In handlers.rs, add your method to the enum:
And update the Display impl:
2b. Implement the Handler
Create a handler struct and implement SaplingRemoteApiHandler:
Hg vs Git Support
By default, handlers only support Hg clients (SUPPORTED_FLAVOURS defaults to [SlapiCommitIdentityScheme::Hg]). Most new endpoints should be Hg-only.
⚠️ Avoid adding new Git SLAPI methods. Git support requires additional work in the location service and is discouraged for new endpoints. If you need Git support, consult with the team first.
Non-streaming Pattern
For single-response endpoints, use stream::once:
See EphemeralPrepareHandler at handlers/commit.rs:862-892.
Streaming Pattern
For endpoints returning multiple items, use stream::iter or try_stream!:
See CommitMutationsHandler at handlers/commit.rs:1117-1152.
2c. Register the Handler
In handlers.rs, add to build_router():
Step 3: Add Client-Side Implementation
Location: fbcode/eden/scm/lib/edenapi/
⚠️ IMPORTANT: Do not land client-side changes until the server-side diff has been deployed. The server must be available first, otherwise clients will call an endpoint that doesn't exist yet.
3a. Add Endpoint Path
In src/client.rs, add to mod paths:
3b. Add Trait Method
In trait/src/api.rs, add the method signature to SaplingRemoteApi:
3c. Implement in Client
In src/client.rs, add the implementation:
Non-streaming (single response)
See ephemeral_prepare_attempt and its trait impl at client.rs:828-850 and 1931-1941.
Streaming (multiple responses)
See commit_mutations at client.rs:1980-2001.
Landing Order
- First diff: Server-side changes (types + handler + registration)
- Land and wait for deployment
- Second diff: Client-side changes
- Do not land until server-side is deployed
- Once server is deployed, land the client diff
Optional: Query String Parameters
If your endpoint needs query parameters (rarely needed, prefer putting params in request body), define a custom extractor:
See UploadBonsaiChangesetQueryString at handlers/commit.rs:151-153.
Testing
- Server-side unit tests can be added alongside handler code
- Integration tests are in
fbcode/eden/mononoke/tests/integration/ - Client-side tests typically use mock servers or
eagerepo
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingeden/.llms/skills/CREATING_ENDPOINTS/SKILL.md
Popularity
- Repository stars
- 6,877
- Repository forks
- 370
- 7-day trend score
- 44
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/facebook/sapling/creating-endpoints)