get_rule
Retrieve specific project rules by name from promptz.dev to access prompt guidelines without switching contexts during development.
Instructions
Get a specific project rule by name
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Name of the rule to retrieve |
Implementation Reference
- src/tools.ts:85-112 (handler)The getRuleToolHandler function implements the core logic for the 'get_rule' tool. It parses the input name, fetches the rule using getRuleByName, formats it into a JSON response, and returns it as tool output.export async function getRuleToolHandler(request: CallToolRequest): Promise<CallToolResult> { const name = request.params.arguments?.name as string | undefined; if (!name) { throw new Error("Rule name is required"); } const rule = await getRuleByName(name); if (!rule) { throw new Error(`Rule not found: ${name}`); } const ruleData = { name: rule.name, description: rule.description, tags: rule.tags || [], author: rule.author?.displayName, content: rule.content, }; return { content: [ { type: "text", text: JSON.stringify(ruleData, null, 2), }, ], }; }
- src/index.ts:84-96 (registration)Registration of the 'get_rule' tool in the list_tools response, including its name, description, and input schema specification.{ name: "get_rule", description: "Get a specific project rule by name", inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the rule to retrieve", }, }, }, },
- src/index.ts:117-119 (registration)Handler routing in the CallToolRequest switch statement that dispatches 'get_rule' calls to getRuleToolHandler.case "get_rule": { return await getRuleToolHandler(request); }
- src/graphql-client.ts:112-138 (helper)Supporting function getRuleByName that queries the GraphQL API to retrieve a specific project rule by its name.export async function getRuleByName(name: string): Promise<ProjectRule | null> { try { logger.info(`[API] Getting rule by name: ${name}`); // Search for prompts with the exact name const { data, error } = await client.query( gql` ${GET_RULE_BY_NAME} `, { name }, ); if (error) { throw error; } const rules = data.listRuleByName.items; if (rules.length === 0) { return null; } return rules[0]; } catch (error) { logger.error(`[Error] Failed to get rule by name: ${error instanceof Error ? error.message : String(error)}`); throw new Error(`Failed to get rule by name: ${error instanceof Error ? error.message : String(error)}`); } }
- src/index.ts:87-95 (schema)Input schema definition for the 'get_rule' tool, specifying a required 'name' string parameter.inputSchema: { type: "object", properties: { name: { type: "string", description: "Name of the rule to retrieve", }, }, },