حوّل الشفرة المصدرية إلى مستندات API يمكن لفريقك استخدامها

Why this prompt matters
Bad API docs slow integration, create support tickets, and turn simple launches into guesswork. A strong prompt helps teams extract the contract from real code, catch missing edge cases early, and ship cleaner developer experience without starting from a blank page.
What we use it for
Use this when you have working API code but weak or outdated documentation, especially before handing an endpoint to frontend engineers, partners, QA teams, or external developers.
Prompt
Role: Act as a senior API platform engineer and technical writer. Context: I will give you source code, route definitions, validators, example payloads, and any notes I have. The code may be incomplete, inconsistent, or lightly documented. Your job is to infer the real API contract from the implementation without inventing behavior that is not supported by the code. Task: Produce complete API documentation for [API NAME] based on the code and notes I provide. Document each endpoint with: purpose, HTTP method, path, authentication requirements, request headers, path/query/body parameters, validation rules, request example, success response example, error responses, important edge cases, and one curl example. If the API behavior is ambiguous, explicitly label the uncertainty and list the exact code area that needs human review. Inputs: - Product/service name: [API NAME] - Intended audience: [INTERNAL DEVELOPERS | PARTNERS | PUBLIC DEVELOPERS] - Source code or route files: [PASTE CODE OR FILE CONTENTS] - Validation schemas / types: [PASTE SCHEMAS] - Auth details: [PASTE AUTH LOGIC OR NOTES] - Known business rules: [PASTE NOTES] Constraints: 1. Do not invent endpoints, fields, or response codes that are not supported by the inputs. 2. Separate confirmed behavior from inferred behavior. 3. Use plain English and keep jargon low unless the code requires it. 4. Include warnings for breaking changes, unsafe defaults, or inconsistent naming. 5. If examples are missing, generate clearly labeled illustrative examples that match the schema. 6. Call out undocumented pagination, rate limits, idempotency behavior, retries, and nullability when visible in code. 7. End with a short section titled "Gaps to confirm with engineering". Output Format: Return the result in this exact structure: 1. API overview 2. Authentication 3. Base URL and versioning 4. Endpoint reference (repeat per endpoint) 5. Error model 6. Common workflows 7. Breaking-change and quality risks 8. Gaps to confirm with engineering
Result
Generated Image

هذا Prompt مناسب للفرق التي تملك API يعمل فعلاً لكن مستنداته ضعيفة أو قديمة. بدلاً من طلب كتابة مستندات بشكل عام، فإنه يدفع النموذج إلى قراءة التنفيذ الحقيقي، وفصل السلوك المؤكد عن الاستنتاج، وإنتاج مادة يمكن للفريق التقني الاعتماد عليها.
البنية هنا مهمة. قسم Role يضع النموذج في دور مهندس منصة API وكاتب تقني معاً. قسم Context يوضح أن الشفرة قد تكون ناقصة أو غير متناسقة، لذلك يجب إظهار الغموض بدلاً من اختراع تفاصيل. أما قسم Task فيطلب العناصر التي تهم في العمل الفعلي: auth وvalidation وبنية request وresponse والأخطاء والحالات الطرفية وأمثلة curl.
قسم Constraints هو ما يجعل هذا Prompt عملياً. فهو يمنع اختراع endpoints أو حقول غير مدعومة، ويطلب تمييز المناطق الغامضة بوضوح، والتنبيه إلى pagination وrate limits وidempotency وretries وnullability. هذه غالباً هي التفاصيل التي تغيب عن المستندات اليدوية.
إذا كنت تعمل مع FastAPI أو Express أو Laravel أو Django أو Rails أو Go أو backends في Java، فهذا Prompt طريقة سريعة لتحويل التنفيذ إلى عقد واضح وقابل للاستخدام. كما أنه مفيد كخطوة QA قبل النشر لأنه يكشف أسماء حقول غير متسقة وأكواد أخطاء غير موثقة.