Skip to content

Commit 3b7596a

Browse files
Merge pull request #19 from intellectronica/claude/review-prompt-01WKGgDY4zFXpQmnc6iH4z5B
Review and refine prompt instructions
2 parents 121bd69 + af8c394 commit 3b7596a

File tree

1 file changed

+134
-15
lines changed

1 file changed

+134
-15
lines changed

src/skillz/_server.py

Lines changed: 134 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,13 @@ def _format_tool_description(skill: Skill) -> str:
817817
raise SkillValidationError(
818818
f"Skill {skill.slug} is missing a description after validation."
819819
)
820-
return description
820+
821+
# Enhanced description that makes it clear this is a skill tool
822+
return (
823+
f"[SKILL] {description} - "
824+
"Invoke this to receive specialized instructions and "
825+
"resources for this task."
826+
)
821827

822828

823829
def register_skill_tool(
@@ -877,17 +883,43 @@ async def _skill_tool( # type: ignore[unused-ignore]
877883
"instructions": instructions,
878884
"usage": textwrap.dedent(
879885
"""\
880-
Apply the skill instructions to complete the task.
881-
882-
If the skill instructions reference additional files or
883-
resources, and you determine it's appropriate to use them
884-
for completing the task, retrieve them from the MCP server
885-
using the resource URIs listed in the 'resources' field.
886-
887-
If your client does not support MCP resources, call
888-
the fetch_resource tool and pass any URI from the
889-
resources array. Example:
890-
fetch_resource(resource_uri="resource://skillz/...")
886+
HOW TO USE THIS SKILL:
887+
888+
1. READ the instructions carefully - they contain
889+
specialized guidance for completing the task.
890+
891+
2. UNDERSTAND the context:
892+
- The 'task' field contains the specific request
893+
- The 'metadata.allowed_tools' list specifies which
894+
tools to use when applying this skill (if specified,
895+
respect these constraints)
896+
- The 'resources' array lists additional files
897+
898+
3. APPLY the skill instructions to complete the task:
899+
- Follow the instructions as your primary guidance
900+
- Use judgment to adapt instructions to the task
901+
- Instructions are authored by skill creators and may
902+
contain domain-specific expertise, best practices,
903+
or specialized techniques
904+
905+
4. ACCESS resources when needed:
906+
- If instructions reference additional files or you
907+
need them, retrieve from the MCP server
908+
- PREFERRED: Use native MCP resource fetching if your
909+
client supports it (use URIs from 'resources' field)
910+
- FALLBACK: If your client lacks MCP resource support,
911+
call the fetch_resource tool with the URI. Example:
912+
fetch_resource(resource_uri="resource://skillz/...")
913+
914+
5. RESPECT constraints:
915+
- If 'metadata.allowed_tools' is specified and
916+
non-empty, prefer using only those tools when
917+
executing the skill instructions
918+
- This helps ensure the skill works as intended
919+
920+
Remember: Skills are specialized instruction sets
921+
created by experts. They provide domain knowledge and
922+
best practices you can apply to user tasks.
891923
"""
892924
).strip(),
893925
}
@@ -945,18 +977,105 @@ def build_server(registry: SkillRegistry) -> FastMCP:
945977
", ".join(skill.metadata.name for skill in registry.skills)
946978
or "No skills"
947979
)
980+
981+
# Comprehensive server-level instructions for AI agents
982+
skill_count = len(registry.skills)
983+
server_instructions = textwrap.dedent(
984+
f"""\
985+
SKILLZ MCP SERVER - Specialized Instruction Provider
986+
987+
This server provides access to {skill_count} skill(s):
988+
{summary}
989+
990+
## WHAT ARE SKILLS?
991+
992+
Skills are specialized instruction sets created by domain experts.
993+
Each skill provides detailed guidance, best practices, and
994+
techniques for completing specific types of tasks. Think of skills
995+
as expert knowledge packages that you can apply to user requests.
996+
997+
## WHEN TO USE SKILLS
998+
999+
Consider using a skill when:
1000+
- A user's request matches a skill's description or domain
1001+
- You need specialized knowledge or domain expertise
1002+
- A task would benefit from expert-authored instructions or best
1003+
practices
1004+
- The skill provides relevant tools, resources, or techniques
1005+
1006+
You should still use your own judgment about whether a skill is
1007+
appropriate for the specific task at hand.
1008+
1009+
## HOW TO USE SKILLS
1010+
1011+
1. DISCOVER: Review available skill tools (they're marked with
1012+
[SKILL] prefix) to understand what specialized instructions
1013+
are available.
1014+
1015+
2. INVOKE: When a skill is relevant to a user's task, invoke the
1016+
skill tool with the 'task' parameter describing what the user
1017+
wants to accomplish.
1018+
1019+
3. RECEIVE: The skill tool returns a structured response with:
1020+
- instructions: Detailed guidance from the skill author
1021+
- metadata: Info about the skill (name, allowed_tools, etc.)
1022+
- resources: Additional files (scripts, datasets, etc.)
1023+
- usage: Instructions for how to apply the skill
1024+
1025+
4. APPLY: Read and follow the skill instructions to complete the
1026+
user's task. Use your judgment to adapt the instructions to
1027+
the specific request.
1028+
1029+
5. RESOURCES: If the skill references additional files or you
1030+
need them, retrieve them using MCP resources (preferred) or
1031+
the fetch_resource tool (fallback for clients without native
1032+
MCP resource support).
1033+
1034+
## IMPORTANT GUIDELINES
1035+
1036+
- Skills provide INSTRUCTIONS, not direct execution - you still
1037+
need to apply the instructions to complete the user's task
1038+
- Respect the 'allowed_tools' metadata when specified - these
1039+
are tool constraints that help ensure the skill works as
1040+
intended
1041+
- Skills may contain domain expertise beyond your training data
1042+
- treat their instructions as authoritative guidance from
1043+
experts
1044+
- You can invoke multiple skills if relevant to different
1045+
aspects of a task
1046+
- Always read the 'usage' field in skill responses for specific
1047+
guidance
1048+
1049+
## SKILL TOOLS VS REGULAR TOOLS
1050+
1051+
- Skill tools (marked [SKILL]): Return specialized instructions
1052+
for you to apply
1053+
- Regular tools: Perform direct actions
1054+
1055+
When you see a [SKILL] tool, invoking it gives you expert
1056+
instructions, not a completed result. You apply those
1057+
instructions to help the user.
1058+
"""
1059+
).strip()
1060+
9481061
mcp = FastMCP(
9491062
name=SERVER_NAME,
9501063
version=SERVER_VERSION,
951-
instructions=f"Loaded skills: {summary}",
1064+
instructions=server_instructions,
9521065
)
9531066

9541067
# Register fetch_resource tool for clients without MCP resource support
9551068
@mcp.tool(
9561069
name="fetch_resource",
9571070
description=(
958-
"Fetch a skill resource by URI for clients that do not support "
959-
"MCP resources. Only supports resource://skillz/{skill-slug}/{path}."
1071+
"[FALLBACK ONLY] Fetch a skill resource by URI. "
1072+
"IMPORTANT: Only use this if your client does NOT support "
1073+
"native MCP resource fetching. If your client supports MCP "
1074+
"resources, use the native resource fetching mechanism "
1075+
"instead. This tool only supports URIs in the format: "
1076+
"resource://skillz/{skill-slug}/{path}. Resource URIs are "
1077+
"provided in skill tool responses under the 'resources' "
1078+
"field."
9601079
),
9611080
)
9621081
async def fetch_resource(

0 commit comments

Comments
 (0)