Synthèse automatique
Cette skill rappelle la sémantique des méthodes HTTP (safety, idempotence, cacheabilité) et aide à choisir la bonne méthode lors de la conception ou de la revue d'un endpoint REST.
Points forts
- Définit clairement safety et idempotence, avec la liste exacte des méthodes concernées
- Donne des exemples de requêtes et de réponses pour GET, POST, PUT, PATCH et DELETE
- Couvre des cas concrets souvent mal traités : requêtes GET avec effet de bord, choix PUT vs PATCH, nouvelle tentative après échec réseau, cache CDN
- Signale des pièges de sécurité, comme les données sensibles dans les query strings
Limites
- Skill purement descriptive : elle ne génère ni code, ni tests, ni outil de validation des contrats
- Ne traite pas les sujets voisins (authentification, versioning, pagination, codes d'erreur au-delà des exemples)
- Le choix de méthode reste un jugement humain dans les cas ambigus, notamment l'idempotence de PATCH selon le format utilisé
À utiliser au moment de concevoir un endpoint REST ou de relire une PR qui emploie POST pour toutes les mutations.
À éviter si le besoin porte sur l'implémentation concrète d'un routeur, la sécurité des API ou la conception de schémas de données.
Analyse de sécurité
SûrThis is a purely educational reference about HTTP method semantics. It contains no executable instructions, tool invocations, credential handling, network calls, or destructive operations, so listing it poses no meaningful execution risk.
Aucun point d'attention détecté
Comment cette analyse est faiteExemples
I'm building an endpoint to update a user profile where the client sometimes sends only one changed field. Should I use PUT or PATCH, and what content type should the request use?Review these endpoints and flag any that violate HTTP method semantics — especially GET requests that change state or POST used where PUT/DELETE belongs.My client retries failed requests automatically. Which HTTP methods are safe to retry without deduplication logic, and which ones need idempotency keys?HTTP Methods
HTTP METHODS ARE THE VERBS OF THE WEB — EACH METHOD CARRIES DEFINED SEMANTICS FOR SAFETY AND IDEMPOTENCY THAT ENABLE CACHING, SAFE RETRIES, AND CORRECT CLIENT BEHAVIOR. CHOOSING THE WRONG METHOD BREAKS THESE CONTRACTS AND FORCES CLIENTS TO GUESS AT SIDE EFFECTS.
When to Use
- Designing a new REST endpoint and choosing the correct HTTP method
- Reviewing a PR that uses POST for all mutations or GET for state changes
- Deciding between PUT and PATCH for a partial-update endpoint
- Explaining to a team why GET requests must not have side effects
- Debugging a CDN that is not caching expected responses
- Implementing a retry strategy and determining which methods are safe to retry
- Evaluating whether a method choice will conflict with CORS preflight requirements
- Auditing an API for methods that violate safe/idempotent contracts
Instructions
Key Concepts
-
Safety — A method is safe if it does not modify server state. GET, HEAD, and OPTIONS are safe. Clients and intermediaries (CDNs, proxies) may freely retry safe requests. A safe method may have side effects (e.g., logging), but those effects must not be visible to the client as resource mutations.
-
Idempotency — A method is idempotent if sending the same request N times produces the same server state as sending it once. GET, HEAD, OPTIONS, PUT, and DELETE are idempotent. POST and PATCH are not idempotent by default. Idempotency enables safe retry on network failure without deduplication logic.
-
GET — Retrieve a resource representation. Safe and idempotent. Must not change state. Responses are cacheable by default. Never put sensitive data in query strings (logged in server access logs, browser history, Referer headers).
GET /orders/ord_abc123 Accept: application/json -
POST — Create a new resource or submit data for processing. Neither safe nor idempotent. Each request may produce a new resource or side effect. The response should include
201 Createdand aLocationheader pointing to the new resource, or200 OKfor processing actions that return a result.POST /orders Content-Type: application/json { "customerId": "cus_99", "items": [{ "sku": "SKU-1", "qty": 2 }] }HTTP/1.1 201 Created Location: /orders/ord_abc123 -
PUT — Replace a resource in full. Idempotent but not safe. The request body must represent the complete desired state. Missing fields are set to null or defaults — not preserved from the prior state. Use PUT when the client constructs the full resource (e.g., file upload to a known key).
PUT /users/42/profile Content-Type: application/json { "name": "Alice", "email": "alice@example.com", "bio": "" } -
PATCH — Apply a partial update to a resource. Not safe, not idempotent (unless the patch format guarantees it). The request body describes a diff or set of operations, not the full resource. Use PATCH when the client only wants to update specific fields. RFC 6902 (JSON Patch) and RFC 7396 (JSON Merge Patch) define standard patch formats.
PATCH /users/42/profile Content-Type: application/merge-patch+json { "bio": "Engineer at Acme Corp" } -
DELETE — Remove a resource. Idempotent but not safe. Idempotency means the server state is identical after N calls as after one — not that the response code must be identical. Return
204 No Contenton success. A second DELETE should return404 Not Found(the resource genuinely does not exist); returning204again is a pragmatic convention that hides this information from callers and should not be chosen by default.DELETE /orders/ord_abc123HTTP/1.1 204 No Content
Worked Example
Stripe's payment API demonstrates correct method semantics across the full lifecycle of a PaymentIntent:
Create a payment intent (POST — not idempotent, creates a new resource):
POST /v1/payment_intents
Content-Type: application/x-www-form-urlencoded
Authorization: Bearer sk_example_...
amount=2000¤cy=usd&customer=cus_99
HTTP/1.1 200 OK
Content-Type: application/json
{
"id": "pi_abc123",
"object": "payment_intent",
"amount": 2000,
"status": "requires_payment_method"
}
Stripe returns 200 OK (not 201) here because the PaymentIntent is not yet a finalized resource, but the creation itself is an acknowledged RPC. This is a documented intentional exception — for standard REST resource creation, prefer 201 Created with a Location header.
Retrieve a payment intent (GET — safe, idempotent, cacheable):
GET /v1/payment_intents/pi_abc123
Authorization: Bearer sk_example_...
Update amount (POST with explicit action — Stripe uses POST for mutations on sub-resources):
POST /v1/payment_intents/pi_abc123
Content-Type: application/x-www-form-urlencoded
amount=3000
Cancel (DELETE equivalent — Stripe models this as POST /cancel action):
POST /v1/payment_intents/pi_abc123/cancel
Stripe's API is a well-known Level 2 departure that uses POST for nearly all mutations. This is a pragmatic choice for form-encoded APIs with complex state machines — but it sacrifices idempotency guarantees. For greenfield REST APIs, prefer PUT/PATCH/DELETE for their semantic precision.
Anti-Patterns
-
Using GET for state-changing operations. A URL like
GET /users/42/deletechanges server state inside a safe method. CDNs will cache it, browsers will prefetch it, and link scanners will trigger it. The consequence can be mass accidental deletion. Always use DELETE for deletion, POST for non-idempotent actions. -
Using POST for all mutations. An API that only exposes POST loses idempotency on updates and deletes, making retry logic complex. Clients cannot determine from the method whether a request is safe to retry. Use PUT/PATCH for updates and DELETE for deletions; reserve POST for creation and non-RESTful actions.
-
Confusing PUT and PATCH. Sending only changed fields via PUT causes the server to null out all omitted fields on a full replace. Sending the full resource body via PATCH is wasteful and confusing to consumers. Document and enforce the semantic: PUT = full replacement, PATCH = partial update. Validate that PUT requests include all required fields.
-
Ignoring HEAD and OPTIONS. HEAD is identical to GET but returns only headers — it allows clients to check resource existence, size, or cache freshness without downloading the body. OPTIONS is used by CORS preflight and by clients discovering allowed methods. Implement both on all resource endpoints; most frameworks provide them automatically.
Details
Method Properties Reference
| Method | Safe | Idempotent | Body | Cacheable | Typical Status | | ------- | ---- | ---------- | ---- | --------- | -------------- | | GET | yes | yes | no | yes | 200 | | HEAD | yes | yes | no | yes | 200 | | OPTIONS | yes | yes | opt | no | 200, 204 | | POST | no | no | yes | rarely | 200, 201 | | PUT | no | yes | yes | no | 200, 204 | | PATCH | no | no | yes | no | 200, 204 | | DELETE | no | yes | opt | no | 200, 204 |
Idempotency and Retries
Network failures occur between request send and response receipt. When the client does not know whether the server received and processed the request, the safest recovery strategy is to retry only idempotent methods (GET, HEAD, PUT, DELETE). For POST and PATCH, the client must use idempotency keys (see api-idempotency-keys) or accept the risk of duplicate processing.
Real-World Case Study: GitHub REST API
GitHub's REST API uses all seven methods with textbook precision. GET /repos/{owner}/{repo}/issues lists issues with CDN caching. POST /repos/{owner}/{repo}/issues creates an issue (returns 201 Created). PATCH /repos/{owner}/{repo}/issues/{issue_number} updates specific fields like title or state. DELETE /repos/{owner}/{repo}/labels/{name} removes a label idempotently. GitHub's disciplined method use means CDN cache hit rates for read-heavy list endpoints exceed 80% on public repos.
Source
- MDN — HTTP Request Methods
- RFC 9110 — HTTP Semantics, Section 9
- RFC 5789 — PATCH Method for HTTP
- RFC 7396 — JSON Merge Patch
- RFC 6902 — JavaScript Object Notation (JSON) Patch
Process
- Identify the operation: retrieving state (GET), creating a new resource (POST), fully replacing a resource (PUT), partially updating a resource (PATCH), or removing a resource (DELETE).
- Check safety and idempotency requirements: if the operation must be safe to retry without side effects, use GET/HEAD/PUT/DELETE. If it may produce duplicate side effects on retry, add idempotency key support or document that clients must not retry blindly.
- Map the response status code to the method: POST creation → 201 with Location; successful mutations with no body → 204; successful mutations returning the updated resource → 200.
- Validate that safe methods (GET, HEAD, OPTIONS) have zero side effects on the resource representation visible to clients.
- Run
harness validateto confirm skill files are well-formed.
Harness Integration
- Type: knowledge -- this skill is a reference document, not a procedural workflow.
- No tools or state -- consumed as context by other skills and agents.
- related_skills: api-status-codes, api-idempotency-keys, api-rest-maturity-model, api-conditional-requests
Success Criteria
- Every endpoint uses the HTTP method whose safety and idempotency properties match the operation's actual behavior.
- GET and HEAD requests produce no visible state changes on any resource.
- PUT requests replace the full resource; PATCH requests update only specified fields.
- POST creation responses return
201 Createdwith aLocationheader. - DELETE and PUT are safe to retry without idempotency keys; POST and PATCH endpoints either accept idempotency keys or document that retries may produce duplicates.
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/http-methods-mrx3xylp/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/http-methods-mrx3xylp' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/http-methods-mrx3xylp/download' --output '.skill-downloads/http-methods-mrx3xylp/SKILL.md.part' && mv '.skill-downloads/http-methods-mrx3xylp/SKILL.md.part' '.skill-downloads/http-methods-mrx3xylp/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Aucune section de prérequis reconnue dans ce fichier. Cela ne signifie pas qu’il est autonome : les bibliothèques, outils et accès peuvent être cités ailleurs dans le contenu ou dans le dépôt source.
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Le fichier ne fournit pas un en-tête name/description exploitable pour cette procédure native. Le téléchargement reste disponible pour lecture ; utilisez le mode manuel ci-dessous.
Mode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/http-methods-mrx3xylp/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.