agentleFS
dekozadekoza/oh-my-slop/skills/reference/pyke/SKILL.md

pyke

Skill4 starsChanged 9 months agoUnlicenseView on GitHub

Use when building, reviewing, or debugging Pyke (Python Knowledge Engine, scitools-pyke) expert-system / logic-programming code — writing .krb/.kfb/.kqb source files, using the knowledge_engine.engine API, pattern matching, rules, plans, the special knowledge base, or question bases. Triggers on: "Pyke", "scitools-pyke", ".krb", ".kfb", ".kqb", "knowledge_engine", "backward chaining", "expert system", "forward chaining".

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill for Pyke work.

    line 18
  2. Distinctive:

    Read only the reference file(s) needed for the task.

    line 23
  3. Very specific:

    If a plan is involved, explain how it is produced (with/plan_spec/taking) and how it is called/pickled.

    line 77

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Pyke (Python Knowledge Engine) Reference

Use this skill for Pyke work. Pyke introduces logic programming (inspired by Prolog) to Python via a knowledge-based inference engine written in 100% Python. You write Python functions and Pyke rules that assemble them into customized call graphs ("plans") for specific use cases.

Read only the reference file(s) needed for the task.

Critical Gotchas

  1. Rule base activation runs forward-chaining rules — engine.activate() fires all forward-chaining rules in the activated rule bases. Assert your facts before activating, or use universal facts / .kfb files loaded at engine creation.
  2. reset() erases case-specific facts and deactivates rule bases — call engine.reset() between cases, then re-assert facts and re-activate.
  3. Goals are strings with $ pattern variables — e.g. family.how_related($p1, $p2, $rel). Pattern variables start with $.
  4. prove_1_goal returns (vars, plan) — vars is a dict (without $) of pattern-variable bindings; plan is a callable (or None). Plans can be pickled.
  5. prove_goal returns a context-manager generator — use with and iterate to get all solutions. Raises no exception when there are no solutions.
  6. CanNotProve is raised only by prove_1_goal — prove_goal returns an empty generator instead.
  7. IDENTIFIER in patterns is a literal — to use a variable, write $name.
  8. Duplicate facts are silently ignored — a fact with the same name and arguments cannot be asserted twice.
  9. assert_ is case-specific — use add_universal_fact for persistent facts, or put facts in .kfb files.
  10. engine constructor scans recursively — .kfb/.krb/.kqb files are found anywhere under the search path; the knowledge-base name is the filename minus its suffix.

Routing

FileUse for
references/api-engine.mdknowledge_engine.engine API, lifecycle, asserting facts, proving goals, tracing, stats
references/rules-syntax.md.krb syntax: fc_rule, bc_rule, use/when/with/taking, plan_spec, first/forall/notany, compound premises, Python premises
references/facts-kb.mdfacts, fact bases, knowledge bases, special KB, question bases
references/pyke-syntax.mdKFB/KRB/KQB source-file syntax, lexical rules, data types
references/pattern-matching.mdpattern syntax, pattern/anonymous/rest variables, matching semantics, context API
references/using-pyke.mdoperational workflow: create engine, assert facts, activate, prove goals, plans, tracing, compiled goals
references/special-qbase.mdspecial.claim_goal/check_command/command/general_command, question-base details
references/examples.mdconcrete examples mirroring the shipped examples/
references/REFERENCE.mdcross-file routing (this is it)

When NOT to Use This Skill

  • Prolog itself — this skill is Pyke-specific (Python integration).
  • Generic rule-engine libraries (e.g. rules_engine, jsonrules) — only Pyke's scitools-pyke package.
  • Pyke 0.x / legacy 0.6 — the 1.1.1 API differs (e.g. engine constructor, prove_goal/prove_1_goal).

Output Expectations

  • Name the source file(s) and knowledge-base name(s) used.
  • State which rule base must be activated and in what order facts are asserted.
  • If a plan is involved, explain how it is produced (with/plan_spec/taking) and how it is called/pickled.
  • State the minimum verification: create an engine, activate, and run a prove_1_goal smoke test against a tiny .kfb/.krb pair.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.