Boost Agent Skills
Discover how to enhance your agent skills with cognee, a memory layer for AI agents, and n8n, a workflow automation tool, in this guest post by Vasilije...
- by Partners
- ai Agents
- Devops Tutorials
- Boost
- Agent
- Skills
By Global Outreach
Discover how to enhance your agent skills with cognee, a memory layer for AI agents, and n8n, a workflow automation tool, in this guest post by Vasilije Marković, CEO and Founder of cognee.
Creating skills for code review, tests, and migrations is straightforward, but maintaining them can be challenging, especially when projects evolve and requirements change.
As projects progress, skill files may become outdated, leading to critical checks being missed, which can be mitigated by implementing a maintenance loop for agent skills.
This tutorial demonstrates how to build a maintenance loop that updates skills based on feedback, ensuring they remain relevant and effective, using cognee and n8n.
There are multiple ways to implement this maintenance loop, depending on your workflow preferences and existing infrastructure.
Choose the approach that best fits your work style and existing tools to streamline your agent skill maintenance.
- Use the n8n editor for a visual, no-code approach, connecting to a cognee server for AI-powered skill updates.
- Self-host n8n and use your own cognee server for a more customized solution.
Both methods produce the same outcome: a weak run becomes an approvable edit to a skill file, using the same example of a code-review skill and authorization-boundary review task.
This tutorial primarily focuses on the visual building approach in the n8n editor, but also covers building the loop with code for more advanced users.
Understanding the roles of cognee and n8n is crucial for effective implementation, with cognee handling AI-related tasks and n8n managing workflow automation.
cognee transforms data from multiple document formats into structured knowledge graphs, enabling AI agents to understand how information pieces are connected.
The Cognee verified node in n8n performs several key jobs, including ingesting skills, reviewing them, proposing improvements, and applying approved changes.
- Ingest Skill: storing a skill as a dataset-scoped skill in cognee.
- Review Skill: running a review task with the skill loaded.
- Propose Improvement: generating a proposed rewrite based on a weak review.
- Get Proposal: fetching the before/after procedure, rationale, and confidence.
- Apply Improvement: applying the approved proposal to the skill.
- Get Skill: reading the updated skill back from cognee.
n8n handles the workflow's orchestration, scoring, threshold checks, approval gates, diffs, notifications, and branching, ensuring a seamless and controlled process.
The workflow ensures that skill files are never quietly rewritten, always requiring approval before applying any proposed changes.
By the end of this tutorial, you will have built a visual workflow that turns a sub-threshold-scoring agent run into a reviewable, approvable update to a Markdown skill file.
The workflow involves several steps, starting with a manual trigger and demo controls, setting values for the skill to run and improve, the review task, and the scoring rubric.
The example used is an authorization-boundary review, where the code under review retrieves a dataset by ID, and the agent should flag missing checks and tests.
Before starting, ensure you have an n8n instance with the Cognee node installed and a cognee server with an LLM and embedding provider configured.
Prepare your environment by installing the necessary components and configuring your cognee server for optimal performance.
- Ensure you have an n8n instance with the Cognee node (v0.5.1 or higher) installed.
- Configure a cognee server with an LLM and embedding provider for review and proposal steps.
- Use Cognee Cloud for a fully managed and serverless experience, or self-host your cognee instance for more control.
- Configure the LLM and embedding providers yourself if self-hosting.
Get started with cognee and enhance your agent skills, whether through cloud deployment or on-prem solutions, and discover the benefits of persistent memory for AI agents.
- Enter your cognee API credentials in n8n for secure authentication.
The entire workflow is managed within the n8n UI, eliminating the need for terminal commands.
Begin by importing the template into your n8n instance to initiate the setup process.
Step 1 involves configuring the run, setting initial values such as the skill name, task text, score instructions, and threshold.
Use the Manual Trigger and Demo Controls Set node to adjust values while testing, including the skill to run, review task, and scoring rubric.
{ "skill_name" : "code-review" , "dataset_name" : "n8n-skill-self-improvement" , "skill_markdown" : "<the SKILL.md body>" , "task_text" : "<the review task>" , "score_instructions" : "Grade your own review per dimension (coverage, correctness, ...) from 0.0 to 1.0." , "score_threshold" : 0.9 , "approved" : "1" }- Set the skill_name and skill_markdown for the skill to improve.
- Define the task_text for the review task to run with the skill loaded.
- Establish score_instructions for the agent to grade its review.
- Determine the score_threshold for deciding whether to improve the skill.
- Set approved to control the approval gate.
Step 2 is about ingesting the skill, where the Ingest Skill operation stores the skill in cognee as a dataset-scoped skill.
The Ingest Skill operation returns a dataset_id, which is reused in later steps for consistency and efficiency.
{ "status" : "completed" , "dataset_name" : "n8n-skill-self-improvement" , "dataset_id" : "3d8f047d-dc45-5fee-9b59-b82e4206711c" , "items" : [{ "name" : "code-review" , "kind" : "skill" , "declared_tools" : [ "memory_search" ] }] }The Review Skill operation runs an agentic completion with the skill loaded, grading its own review based on the score_instructions rubric.
This step is crucial as it determines whether the skill needs improvement based on the review score.
The sample task demonstrates an authorization-boundary review, highlighting missing checks and tests that the agent should flag.
{ "score" : 0.42 , "missing_instruction" : "No explicit owner / non-owner / missing-dataset test requirement" , "result_summary" : "Flagged the ownership gap but missed the test matrix" , "dimensions" : [{ "name" : "coverage" , "score" : 0.4 }, { "name" : "correctness" , "score" : 0.45 }] }The review score is then used to decide whether the skill needs improvement, branching the workflow accordingly.
The agent returns a structured review, including flags for missing ownership checks, 404 handling, and specific tests.
Step 4 involves deciding whether to improve the skill based on the review score and threshold.
The Should Improve? IF node compares the review score to the threshold, determining the next steps in the workflow.
If the score is below the threshold, the workflow proceeds to improve the skill; otherwise, it exits, indicating no improvement is needed.
The threshold decision is owned by n8n, making it easy to adjust or replace with stricter evaluators without affecting cognee steps.
The division of labor is clear: the agent grades its review, the verified node parses the score, and n8n decides on the threshold and subsequent actions.
Step 5 proposes an improvement, where the Propose Improvement operation records the weak run and generates a proposed rewrite.
Critically, this step creates a proposal without applying it, ensuring that changes are reviewed and approved before implementation.
{ "items" : [ { "kind" : "skill_run" , "run_id" : "82a14c99…" , "success_score" : 0.42 }, { "kind" : "skill_improvement_proposal" , "proposal_id" : "48d6f3f3-430f-460c-bf5b-2987086a43dd" , "status" : "proposed" } ] }The proposed change remains in a holding state until n8n decides on the next steps, preventing silent rewrites of instructions.
Step 6 reviews the diff before approving, ensuring the proposed change is acceptable and meets requirements.
The Get Proposal operation returns the proposal's before/after, rationale, and confidence, which are then turned into a unified diff for easier review.
{ "proposal_id" : "48d6f3f3-430f-460c-bf5b-2987086a43dd" , "skill_id" : "a49f5ceb-fe79-5094-bee6-ee1de4d45671" , "confidence" : 0.93 , "rationale" : "Clarifies and tightens existing rules so agent outputs strictly-structured, minimal issue reports focused on authorization, tests, and audit logging…" , "old_procedure" : "# code-review …" , "proposed_procedure" : "# code-review …" }This diff can be used in a Slack message or a pull request, making it easy to inspect and approve changes.
1. Read the diff file-by-file and hunk-by-hunk. - Do not run or apply changes. + Do not run, apply, or modify code. Do not mutate state. 3. Authorization and data-access checks: - Apply one of these two patterns and verify the diff shows it: - - Caller-side validation (preferred if get_dataset doesn't accept a requesting user): + Caller-side validation is REQUIRED unless the get_dataset-enforces-acl pattern is present: dataset = get_dataset(requested_dataset) if dataset is None: return 404 if dataset.owner_id != user.id and not user_has_access(user, dataset): return 403 + If the check is missing or weakened, mark the issue Critical and supply the exact pseudo-diff. + 12. Failure-evidence handling: turn a "return get_dataset(requested_dataset)" example into a + Critical issue with the caller-side patch, repro steps, and a short-term mitigation. + 13. Enforcement checklist: before finishing, confirm every issue has the required fields.The example shows how the skill is updated, with changes to the ownership check, severity, and enforcement sections, demonstrating the effectiveness of the proposal and review process.
Step 7 applies the approved change, where the Approved? IF node checks the approval flag and, upon approval, updates the stored skill in cognee.
The Apply Improvement operation flips the status to applied, ensuring that the updated skill is used in subsequent runs.
Step 8 confirms the result, where the Get Skill operation reads the skill back to verify the changes, and Show Skill Delta emits the final diff.
{ "items" : [{ "kind" : "skill_improvement_proposal" , "proposal_id" : "48d6f3f3…" , "status" : "applied" }] }This final step ensures that the updated skill is live and effective, completing the maintenance loop.
The visual build allows running the entire loop without writing code, making it accessible and efficient for maintaining agent skills.
Adapting the visual build for production involves replacing demo controls with more robust triggers and approval mechanisms, such as webhooks and Slack nodes.
The division of labor remains consistent, with n8n handling orchestration and cognee managing AI-related tasks, ensuring a scalable and maintainable solution.
For advanced users, a self-hosted solution with a Python SDK build is available, offering more control and customization options.
- Replace Demo Controls with a Webhook Trigger or a Slack node for more robust automation.
- Implement a Wait node or webhook callback for approval, ensuring changes are reviewed before application.
- Use a GitHub branch and pull request for skill changes, integrating with existing code review processes.
The key to a successful maintenance loop is the clear division of labor between n8n and cognee, ensuring that each tool is used to its strengths.
For those preferring a self-hosted solution with more control, the advanced template using the Python SDK is a viable option, though it requires more setup and technical expertise.
The advanced template performs the same tasks as the visual build but uses the Python SDK for cognee interactions, offering a more customizable solution for advanced users.
python run_self_improve_skill.py init-state python run_self_improve_skill.py remember-skills python run_self_improve_skill.py run-agent python run_self_improve_skill.py record-feedback python run_self_improve_skill.py review-packet python run_self_improve_skill.py apply-proposalThis approach requires enabling executeCommand in n8n 2.x due to security defaults, but provides a highly hackable and local solution.
The maintenance loop ensures that agent skills keep pace with project evolution, reflecting current project workings rather than outdated instructions.
By implementing this loop, you can ensure that your agent skills remain valuable and effective, adapting to changes in the project over time.
Start with the visual workflow template and one skill to see how the maintenance loop works, then expand to more skills and adapt the workflow as needed for your project.
Useful resources are available to support your journey with cognee and n8n, including documentation, workflow templates, and community support.
- cognee documentation for in-depth information on using cognee with n8n.
- Cognee node in n8n for workflow automation.
- Workflow templates for both no-code and advanced users.
The n8n community is diverse and active, with users from various backgrounds and experience levels, and sharing your projects and experiences can inspire and help others.
Want help putting this into practice?
Global Outreach builds ERP, VoIP, and custom software for businesses in Pakistan.
Start a conversation