Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs: improve prompt quality — language detection, tab labels, cleanup

Sushmitha Mallesh4b2040f4d497
diff --git a/docs/components/quickstart/prompt-banner.tsx b/docs/components/quickstart/prompt-banner.tsx
index ebb06c0ac..39977cef6 100644
--- a/docs/components/quickstart/prompt-banner.tsx
+++ b/docs/components/quickstart/prompt-banner.tsx
@@ -11,6 +11,22 @@ export function PromptBanner({ children }: PromptBannerProps) {
const [copied, setCopied] = useState(false);
const contentRef = useRef<HTMLDivElement>(null);
+ const detectLang = (pre: Element): string => {
+ // Check data-language on <pre> or <code>
+ const code = pre.querySelector('code');
+ const dataLang = pre.getAttribute('data-language') ?? code?.getAttribute('data-language');
+ if (dataLang) return dataLang;
+ // Check class="language-xxx"
+ const cls = Array.from(code?.classList ?? []).find(c => c.startsWith('language-'));
+ if (cls) return cls.replace('language-', '');
+ // Guess from content
+ const text = code?.textContent ?? '';
+ if (text.includes('pip install') || text.includes('npm install')) return 'bash';
+ if (text.includes('import ') && text.includes('from ')) return 'python';
+ if (text.includes('import ') && text.includes('from "')) return 'typescript';
+ return '';
+ };
+
const extractSteps = (stepsEl: Element): string => {
const parts: string[] = [];
const steps = stepsEl.querySelectorAll('.fd-step');
@@ -20,20 +36,22 @@ export function PromptBanner({ children }: PromptBannerProps) {
const title = step.querySelector('h3, h4, [class*="StepTitle"]');
if (title) parts.push(`### ${title.textContent?.trim()}`);
- // Code blocks — preserve as fenced code
- const codeBlocks = step.querySelectorAll('pre code');
- codeBlocks.forEach((code) => {
- // Try to detect language from class (e.g. "language-python")
- const langClass = Array.from(code.classList).find(c => c.startsWith('language-'));
- const lang = langClass?.replace('language-', '') ?? '';
- parts.push(`\`\`\`${lang}\n${code.textContent?.trim()}\n\`\`\``);
- });
-
- // Callouts / prose text (skip if it's just whitespace)
- const paragraphs = step.querySelectorAll(':scope > p, :scope > div:not(:has(pre)) > p');
- paragraphs.forEach((p) => {
- const text = p.textContent?.trim();
- if (text) parts.push(text);
+ // Find code blocks, checking if they're inside tabs
+ const pres = step.querySelectorAll('pre');
+ pres.forEach((pre) => {
+ const lang = detectLang(pre);
+ const code = pre.querySelector('code')?.textContent?.trim() ?? '';
+ if (!code) return;
+
+ // Check if inside a tab panel — use tab name as label
+ const tabPanel = pre.closest('[role="tabpanel"]');
+ const tabId = tabPanel?.getAttribute('data-value') ?? tabPanel?.getAttribute('aria-labelledby');
+ if (tabId) {
+ const label = tabId.replace(/-/g, ' ');
+ parts.push(`**${label}**\n\n\`\`\`${lang}\n${code}\n\`\`\``);
+ } else {
+ parts.push(`\`\`\`${lang}\n${code}\n\`\`\``);
+ }
});
});
diff --git a/docs/content/docs/quickstart.mdx b/docs/content/docs/quickstart.mdx
index 652211b2a..567bfeeda 100644
--- a/docs/content/docs/quickstart.mdx
+++ b/docs/content/docs/quickstart.mdx
@@ -57,7 +57,6 @@ from composio_core import Composio
4. Are API keys in .env, not hardcoded?
5. Are imports from `composio` (Python) or `@composio/core` (TS)?
-Latest docs: https://docs.composio.dev/docs/quickstart
</PromptBanner>
<Steps>
@@ -241,7 +240,6 @@ from composio_core import Composio
4. Is `require_approval` set to `"never"` in Python?
5. Are API keys in .env, not hardcoded?
-Latest docs: https://docs.composio.dev/docs/quickstart
</PromptBanner>
<Steps>
@@ -445,7 +443,6 @@ from composio_core import Composio
4. Is the code using `async/await`?
5. Are API keys in .env, not hardcoded?
-Latest docs: https://docs.composio.dev/docs/quickstart
</PromptBanner>
<Steps>
@@ -655,7 +652,6 @@ from composio_core import Composio
5. Is the code using `async/await`?
6. Are API keys in .env, not hardcoded?
-Latest docs: https://docs.composio.dev/docs/quickstart
</PromptBanner>
<Steps>
@@ -881,7 +877,6 @@ const result = await generateText({ model, tools, prompt });
4. Is `maxSteps` set in `streamText` / `generateText`?
5. Are API keys in .env, not hardcoded?
-Latest docs: https://docs.composio.dev/docs/quickstart
</PromptBanner>
<Steps>
@@ -1026,7 +1021,6 @@ const result = await generateText({ model, tools, prompt });
5. Is `client.close()` called when done?
6. Are API keys in .env, not hardcoded?
-Latest docs: https://docs.composio.dev/docs/quickstart
</PromptBanner>
<Steps>