add-endpoint
Skill134 starsChanged 3 months agoMITView on GitHub
Add a new FastAPI endpoint to APIView Copilot. Use for: add endpoint, new endpoint, new API route, add route, create endpoint, add API, new POST endpoint, new GET endpoint.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- nikzlabs/shipittheir own version, first seen Oct 2, 2026
- aiqadam/qadam-flowtheir own version, first seen Sep 20, 2026
- atherio-danp/cde-dotnetcctheir own version, first seen Jun 19, 2026
- paulieb89/property-sharedtheir own version, first seen May 3, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- atherio-danp/cde-dotnetcc★ 109same name
- paulieb89/property-shared★ 16same name
- nikzlabs/shipit★ 9same name
- aiqadam/qadam-flow★ 4same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository42 other files it gives its agents.
- packages/python-packages/apiview-copilot/AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- azsdk-common-apiview-feedback-resolutionSkill
- azsdk-common-generate-sdk-locallySkill
- azsdk-common-generate-sdk-pipelineSkill
- azsdk-common-pipeline-analysisSkill
- azsdk-common-pipeline-fixerSkill
- azsdk-common-prepare-release-planSkill
- azsdk-common-sdk-breaking-changeSkill
- azsdk-common-sdk-releaseSkill
- azure-typespec-assessmentSkill
- azure-typespec-authorSkill
- code-reviewSkill
- eval-authoring-skillSkill
- eval-authoring-toolSkill
- eval-authoring-workflowSkill
- markdown-token-optimizerSkill
- sdk-ai-bot-eval-datasetSkill
- sdk-ai-bot-run-evaluationSkill
- skill-authoringSkill
- audit-filtersSkill
- dev-setupSkill
- kb-searchSkill
- report-active-reviewsSkill
- report-apiview-metricsSkill
- report-architect-commentsSkill
- report-feedbackSkill
- report-memorySkill
- report-revisionsSkill
- run-evalsSkill
- run-metricsSkill
- update-guidelinesSkill
- apiview-feedback-resolutionSkill
- azure-typespec-authorSkill
- generate-sdk-locallySkill
- azsdk-common-live-and-recorded-testsSkill
- markdown-token-optimizerSkill
- pipeline-troubleshootingSkill
- azsdk-common-prepare-release-planSkill
- azsdk-common-sdk-releaseSkill
- skill-authoringSkill
- pr-review-helpSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
15 rules. 0 are common, 4 are distinctive, and 11 are very specific to this project.
0
Common
Most of the 4 edited versions we read keep these.
4
Distinctive
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 10
When adding a new endpoint, follow every step below.
- Very specific: line 14
Place models near where they're used — in app.py for endpoint-specific models, or in src/_models.py for shared/reusable models.
- Distinctive: line 15
All multi-word field names MUST use camelCase aliases: Never expose snake_case in the JSON API.
- Very specific: line 16
Add class Config with populate_by_name = True on any model that has aliases so it can be constructed with either the Python name or the …
- Very specific: line 17
Use Field(...) for required fields, Field(None, ...) or Field(default=..., ...) for optional ones.
- Distinctive: line 18
Every model must have a triple-double-quote docstring.
- Very specific: line 60
Use @app.post(...) or @app.get(...) etc.
- Very specific: line 62
Add Depends(require_roles(...)) for authentication.
- Distinctive: line 63
Add a docstring describing the endpoint.
- Very specific: line 89
No extra by_alias=True call is needed — FastAPI handles this via the response_model.
- Very specific: line 90
When constructing a response object in code, use the Python field names: MyFeatureResponse(job_id=..., result_count=...).
- Very specific: line 94
Every endpoint must have a CLI command in cli.py with a --remote flag.
- Very specific: line 143
Use _build_auth_header() for remote authentication.
- Very specific: line 144
Use SettingsManager().get("WEBAPP_ENDPOINT") for the base URL.
- Very specific: line 167
Use type=resolve_language_to_canonical for language params (already global).
“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Add a FastAPI Endpoint
Checklist
When adding a new endpoint, follow every step below.
1. Define Pydantic request/response models
- Place models near where they're used — in
app.pyfor endpoint-specific models, or insrc/_models.pyfor shared/reusable models. - All multi-word field names MUST use camelCase aliases. Never expose snake_case in the JSON API.
- Add
class Configwithpopulate_by_name = Trueon any model that has aliases so it can be constructed with either the Python name or the alias. - Use
Field(...)for required fields,Field(None, ...)orField(default=..., ...)for optional ones. - Every model must have a triple-double-quote docstring.
Example
class MyFeatureRequest(BaseModel):
"""Request model for my feature."""
review_id: str = Field(..., alias="reviewId")
language: str
include_deleted: bool = Field(False, alias="includeDeleted")
max_results: Optional[int] = Field(None, alias="maxResults")
class Config:
"""Configuration for Pydantic model."""
populate_by_name = True
class MyFeatureResponse(BaseModel):
"""Response model for my feature."""
job_id: str = Field(..., alias="jobId")
result_count: int = Field(..., alias="resultCount")
class Config:
"""Configuration for Pydantic model."""
populate_by_name = TrueRules
| Rule | Correct | Wrong |
| JSON field casing | "reviewId" | "review_id" |
| Alias declaration | Field(..., alias="reviewId") | bare review_id: str for multi-word names |
| Config on aliased models | class Config: populate_by_name = True | missing Config |
| Single-word fields | language: str (no alias needed) | language: str = Field(..., alias="language") |
2. Define the endpoint function
- Use
@app.post(...)or@app.get(...)etc. withresponse_model=pointing to the response model. - Set
status_code=when it's not the default 200 (e.g.,202for async jobs). - Add
Depends(require_roles(...))for authentication. UseAppRole.READER/AppRole.APP_READERfor read-only,AppRole.WRITER/AppRole.APP_WRITERfor mutations. - Add a docstring describing the endpoint.
- Wrap business logic in try/except and raise
HTTPExceptionwith appropriate status codes. - For long-running work, use
asyncio.to_thread(...)or background tasks.
Example
@app.post("/my-feature", response_model=MyFeatureResponse)
async def my_feature(
request: MyFeatureRequest,
_claims=Depends(require_roles(AppRole.READER, AppRole.APP_READER)),
):
"""Handle my feature requests."""
try:
result = await asyncio.to_thread(do_work, review_id=request.review_id)
return MyFeatureResponse(job_id=result.id, result_count=result.count)
except Exception as e:
logger.error("Error in /my-feature: %s", e, exc_info=True)
raise HTTPException(status_code=500, detail="Internal server error") from e3. Serialization
FastAPI automatically serializes response models by alias when response_model is set. This means:
- The JSON response will use the alias names (
jobId,resultCount), not the Python names. - No extra
by_alias=Truecall is needed — FastAPI handles this via theresponse_model. - When constructing a response object in code, use the Python field names:
MyFeatureResponse(job_id=..., result_count=...).
4. Add a corresponding CLI command
Every endpoint must have a CLI command in cli.py with a --remote flag. The core logic must be shared between remote and local paths to the maximum extent practical.
Architecture: shared core function
Extract the business logic into a standalone function (in src/ or at module level in cli.py) that both the endpoint and the CLI's local path call. The CLI's --remote path sends an HTTP request to the endpoint instead.
┌─────────────┐
│ core logic │ ← shared function in src/
│ (do_work) │
└──────┬──────┘
│
┌────────────┴────────────┐
│ │
┌──────┴──────┐ ┌──────┴──────┐
│ app.py │ │ cli.py │
│ endpoint │ │ (local) │
└─────────────┘ └─────────────┘
│
if --remote:
HTTP POST → endpointCLI handler pattern
def my_feature(language: str, review_id: str, include_deleted: bool = False, remote: bool = False):
"""Describe the command."""
if remote:
# Remote: HTTP call to the deployed endpoint
settings = SettingsManager()
base_url = settings.get("WEBAPP_ENDPOINT")
payload = {"language": language, "reviewId": review_id, "includeDeleted": include_deleted}
resp = requests.post(
f"{base_url}/my-feature", json=payload, headers=_build_auth_header(), timeout=60
)
if resp.status_code == 200:
print(json.dumps(resp.json(), indent=2))
else:
print(f"Error: {resp.status_code} - {resp.text}")
else:
# Local: call shared core logic directly
result = do_work(language=language, review_id=review_id, include_deleted=include_deleted)
print(json.dumps(result, indent=2))Key rules:
- The
--remotepayload must use camelCase keys matching the endpoint's request model aliases. - Local mode calls the same core function that the endpoint calls.
- Use
_build_auth_header()for remote authentication. - Use
SettingsManager().get("WEBAPP_ENDPOINT")for the base URL.
Register the command
In CliCommandsLoader.load_command_table, add the command to the appropriate CommandGroup:
with CommandGroup(self, "review", "__main__#{}") as g:
# ... existing commands ...
g.command("my-feature", "my_feature")Register any command-specific arguments in load_arguments:
with ArgumentsContext(self, "review my-feature") as ac:
ac.argument("review_id", options_list=["--review-id", "-r"], help="The review ID.")
ac.argument("include_deleted", action="store_true", help="Include deleted items.")Notes:
--remoteand--languageare already registered globally — don't re-register them.- Knack maps function parameter names to CLI flags automatically (e.g.,
review_id→--review-id). - Use
type=resolve_language_to_canonicalfor language params (already global).
5. Common pitfalls to avoid
- Never return raw dicts with snake_case keys from an endpoint. Always use a typed response model.
- Never omit
alias=on multi-word field names. The API contract is camelCase. - Never use
model_config = ConfigDict(alias_generator=to_camel)— this project uses explicitalias=per field, not automatic generators. - Never forget
populate_by_name = Trueon models with aliases — without it, the model can't be constructed using Python field names. - Never duplicate core logic between the endpoint and the CLI local path. Extract it into a shared function in
src/. - Never use snake_case keys in the remote payload — the
--remotepath must send camelCase keys matching the request model aliases. - Never re-register
--remoteor--languagein command-specificArgumentsContext— they are global.
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.

