构建 Cashfree Agent 技能:面向 AI 编码助手的情境感知知识层

#Tech

构建 Cashfree Agent 技能:面向 AI 编码助手的情境感知知识层

Cashfree 开发了一种名为 Agent Skills 的新型知识层,旨在提高 AI 编码助手在处理特定产品集成任务时的效率和准确性,尤其是在支付领域。

Agent Skills 将 Cashfree 的集成、API、SDK、迁移和故障排除知识打包成可安装的技能,并支持 Claude Code、Codex、Cursor、OpenCode、Copilot 等多种 AI 编码助手。

该系统采用双层结构,核心流程放在 SKILL.md 中,详细信息和边缘案例放在 REFERENCE.md 中,从而提供按需的深度信息。

Agent Skills 通过明确意图路由,确保开发者问题能够被导向到正确的技能,并能在 7 分钟内完成 Cashfree 集成。

查看原文开头(英文 · 仅前 3 段)

7 min read21 hours ago--Press enter or click to view image in full sizeAI coding assistants are now part of how most developers work. They can explain code, generate boilerplate, and help teams move faster. But when the task becomes product-specific, especially in payments, their answers often start to fall apart.For example, a single incorrect webhook verification can mark a failed payment as successful, and trigger fulfilment for an order that was never paid. That is not a hypothetical. It is what happens when a developer implements “something reasonable” instead of the exact verification logic the payment gateway requires.For a Cashfree integration, a developer needs more than just sample code. They require the right order flow, correct webhook verification logic, proper status checks, an ideal migration path, and suitable testing steps. A nearly correct answer is still dangerous. In payments, being “almost right” leads to failed checkouts, broken fulfilment, refund confusion, and repetitive support tickets.That problem is what led us to build Cashfree Agent Skills.Agent Skills are a product-aware knowledge layer for AI coding assistants. They package Cashfree’s integration, API, SDK, migration, and troubleshooting knowledge into installable skills that the assistant can use inside the developer’s normal workflow.Instead of forcing a developer to jump across docs, dashboard settings, old tickets, and tribal knowledge, Cashfree Agent Skills help the assistant answer with Cashfree-specific context at the right moment.Available across Claude Code, Codex, Cursor, OpenCode, Copilot, etc. Cashfree Agent Skills ensures that integration is completed within 7 minutes.Why Generic AI Fails in PaymentsGeneric AI tools are built for breadth, not depth. When a developer asks how to create a Cashfree order, verify a webhook, or handle a refund, the answer they get may be technically coherent but operationally wrong. A missing required field, a skipped verification step, a flow that works in testing and fails in production. The cost shows up later in debugging time, in repeated questions to internal teams, and in integrations that are only as good as the developer’s prior knowledge of the edge cases.How the Skill Files Are StructuredEach skill is split into two layers:SKILL.md for the core workflowREFERENCE.md for deeper details, payloads, schemas, and edge cases.This gives us progressive disclosure.The assistant reads the core path first. If the task needs more depth, it loads the reference file. That keeps answers focused while still allowing depth when the user needs it.In practice, this means a developer asking “integrate Cashfree in my server-side app” gets a direct answer quickly, while a developer asking “how do I verify payment status after a mobile SDK callback and handle retries?” can get much deeper implementation guidance without every response becoming a wall of text.Building Cashfree Agent SkillsThe Core Idea: Treat Product Knowledge as SkillsWe did not want to solve this by dumping more documentation into prompts. That increases noise, wastes tokens, and exhausts the usage limit, and still does not tell the assistant when to use which information.Instead, we structured the knowledge as skills.Each skill is focused on a specific developer task or product area, such as:Getting startedBackend SDK integrationMobile SDKsWebhooksRefundsPayoutsSecure IDSettlements and reconciliationSubscriptionsAuto collectPayment linksGo-liveValidation and testingMigration from other Payment GatewaysThis makes the assistant much easier to route. A webhook problem goes to the webhook skill. A migration problem goes to a migration skill. A go-live question goes to the go-live skill. The result is not just more information. It is more relevant information.How Agent Skills WorkWe packaged the system as a CLI so teams can install it into their preferred AI coding assistant with one command:npx @cashfreepayments/agent-skills add skillsFrom installation to a working Cashfree integration in under 7 minutes. The CLI installs skill files into the assistant-specific skills directory and adds a manifest file that lists the available skills and how to use them.That manifest is important. It acts as the routing layer. It tells the assistant:Where the Cashfree skills liveWhich skill to use for which developer goalWhich shared conventions to followWhich validation skill should be read after implementation?On correctness, each skill is scoped to a single happy path. There is no catch-all skill that can handle every edge case in a single file. If a flow has a known dangerous shortcut, like trusting a mobile SDK callback without server-side verification, the skill explicitly calls it out as incorrect and shows the right pattern. The two-layer structure (SKILL.md + REFERENCE.md) also means the assistant gets the minimal correct implementation first, before it can drift into an edge case that does not apply.Get Aaryan Singh’s stories in your inboxJoin Medium for free to get updates from this writer.Remember me for faster sign inWe also made the system work across various AI coding assistants. That way, the knowledge layer is portable even if developer workflows differ.Press enter or click to view image in full sizeHow We Built the SkillsEach skill starts from the actual integration path, not from the documentation structure. We ask: What does a developer need to do to complete this task correctly, end to end? The answer becomes skill.The primary source is Cashfree’s own API reference, SDK documentation, and known integration patterns. We layer on top of that the edge cases and operational details.How We Ensure Skills Are AI-FriendlyWriting for an AI assistant is different from writing for a human reader. We apply a few specific constraints.Instruction-first structure. Every skill opens with what the assistant should do, not background context. The model needs to orient quickly, so the action comes before the explanation.Explicit negative patterns. Where there is a common wrong implementation, the skill names it directly and shows the correct alternative. An AI assistant that only knows what is correct can still infer the wrong pattern from training data. Calling out the antipattern explicitly overrides that.Scoped to one task. Each skill covers one integration flow. No skill tries to be comprehensive across multiple products or scenarios. The narrower the scope, the more reliably the assistant stays on the correct path without drifting into adjacent flows that do not apply.Code examples that work as-is. All code in skills uses real field names, real header values, and the current API version. Nothing is pseudocode. The assistant should be able to adapt the example to the developer’s stack without needing to cross-reference the actual docs.Where This Becomes Especially ValuableThe biggest improvement shows up in high-friction workflows.For example:A webhook question can route to product-specific webhook guidance instead of generic HTTP advice.A refund question loads the full implementation logic, eligibility rules, lifecycle handling, and the decision points around the API call, not just the endpoint itself.A testing question can route to a validation checklist instead of ad hoc suggestions.A migration question can map old-provider concepts to Cashfree instead of pretending the integration starts from zero.How Is This Different from a Typical RAG-Based Solution?RAG retrieves chunks by embedding similarity and lets the model sort out relevance. That breaks down for implementation workflows, a webhook question might surface SDK changelogs and payload schemas instead of the actual verification logic, because they all look similar in the embedding space.Agent Skills uses explicit intent routing instead. The manifest maps developer goals to the right skill directly. Each skill loads only what the task needs, core path first, deep reference on demand. Cross-cutting rules like “always verify server-side after a mobile callback” are injected globally, not left to chance in retrieved chunks.Less like a search engine over docs. More like a developer who actually read the integration guide.ImpactAgent Skills are not meant to replace documentation. They make documentation usable inside the coding workflow.Improved results compared to Generic AIPress enter or click to view image in full sizeToken EfficiencySkills also reduce the cost of running AI assistants on payment integration tasks.A common alternative is to have the AI search through documentation at query time, retrieving the most semantically similar chunks and loading them into context. That still pulls thousands of tokens per query, and because retrieval is driven by similarity rather than intent, a large portion of what gets loaded is not actually relevant to what the developer is asking.Agent Skills invert this. The assistant loads only the skill file that matches the current intent. A webhook question loads the webhook skill. A refund question loads the refund skill. Nothing else enters the context unless it is needed. On models that charge per input token, this difference adds up quickly across a team’s daily usage.The two-layer structure compounds this further, the core skill covers the happy path in a few hundred lines, and the deep reference is only pulled when the task genuinely requires it. Most queries never touch the reference layer at all.So if the system works well, the benefits are straightforward:Faster onboarding for developers integrating CashfreeBetter answer quality from AI assistants on Cashfree-specific tasksLower repetitive support load for documented questionsFaster implementation across backend, frontend, and mobile flowsBetter migration support for merchants switching from other providersMore consistent guidance across engineering, solutioning, and support teamsThe value is not just better content. The value is getting the right content at the right time.ConclusionAI assistants are already part of software development. The real question is whether they stay generic or become genuinely useful for product-specific work.For payments, precision matters. Integration order matters. Operational details matter. Migration assumptions matter.Agent Skills are our way of closing that gap.By packaging Cashfree knowledge into installable, task-aware skills, we can turn a generic coding assistant into a much more reliable companion for implementation, migration, testing, and troubleshooting.That is a better experience for developers, a better support surface for teams, and a stronger foundation for AI-assisted developer experience going forward.

※ 出于版权考虑,仅引用前 3 段。完整内容请阅读原文。

阅读原文 ↗