Agent_primitives – tie each app behaviour to the specs that prove it A new Ruby gem called agent_primitives ties each app behaviour to the RSpec examples that prove it, so coding agents can read a repository's intent clauses before planning or changing code. The gem stores capability docs in a docs/primitives/ directory, tags proving RSpec examples with an intent: ID, and ships three commands — evals, guard and proofs — plus ten skills installed via an import command. The evals command fails CI when an intent clause of a built capability doc has no tagged example, or when a tag names an intent clause that does not exist. Code shows what an app does today. Code does not show what the app must continue to do, or why. Code does not show which spec proves each required behaviour. When coding agents write most of the code, no one keeps this knowledge. Each new agent session starts without it. The results are concrete. An agent changes a deliberate decision because the decision looks like a bug. An agent proposes an alternative that you rejected before. An agent deletes or weakens the spec for a required behaviour, and the suite stays green. agent primitives keeps this knowledge in your repository, next to the code. Each capability of the app gets a capability doc. The capability doc states what the capability must do, as numbered intent clauses. Tagged RSpec examples prove each intent clause. Before an agent plans or changes code, it reads the capability doc or an excerpt of it. The primitives tree is the docs/primitives/ directory. It contains the capability docs. Each RSpec example that proves an intent clause has an intent: tag with the ID of that intent clause. Three commands check the primitives tree: - evals fails CI when an intent clause of a built capability doc has no tagged example. It also fails when a tag names an intent clause that does not exist. - guard reports what a change did to the intent clauses and to the examples that prove them. - proofs lists the tagged examples that prove each intent clause. Ten skills tell your agent when to read, write and check the primitives tree, from planning to review. The import command copies these skills into the skills directory of your agent. What you get: - A change that removes or weakens a tagged example shows in the guard output. If no tagged example remains, evals fails. - guard reports each changed intent clause. The skills tell the agent that only your decision can change an intent clause. - Each capability doc keeps a history of decisions and rejected alternatives. The planning agent reads this history before it proposes an approach. The review agent reports a change that reverses a recorded decision. - Your planning and implementing workflows write the primitives tree. Your review workflow checks it. You do not write documentation as a separate task. Each capability doc records four things. | Part | Location | Contents | |---|---|---| | Intent | intent: in the frontmatter | Numbered intent clauses. Each intent clause states one thing that must be true. I1 — A reader can reply to any comment. | | Shape | Shape section | Constraints that the implementation must obey, in addition to the framework defaults. | | Evaluations | evaluations: on each intent clause | The spec files that prove the intent clause. | | Provenance | Provenance section | A history of decisions, rejected alternatives and accepted debt. Agents add entries and never change them. | docs/primitives/ SCHEMA.md the format contract index.md one line for each capability doc compilation.md constraints for the whole app — you own this file capabilities/ one capability doc for each capability Each capability doc keeps its intent clauses and its evaluations in YAML frontmatter. The commands read this frontmatter. The intent: tag is RSpec metadata: it "shows replies nested under their parent", intent: "comment threads I2" do An example with an intent: tag is a tagged example. An evaluation names the spec file that contains the tagged examples for one intent clause. Use the same tag to run the tagged examples for one intent clause: bundle exec rspec --tag 'intent:comment threads I2' 1. Add the gem to your Gemfile : gem "agent primitives", group: :development 2. Install the gem: bundle install 3. Import the skills. The next section gives the procedure. The import command copies the ten skills into a directory. Use the directory that your editor reads skills from. bundle exec agent primitives import .claude/skills The directory must exist. If the directory does not exist, import stops with an error. Without this rule, a mistyped path would create a directory that no editor reads. import adds and updates files. It never deletes a file. - It adds each skill file of the gem that is not in the directory. - It updates a skill file of the gem when the version in the gem is different. - It does not change a file that is identical to the version in the gem. - It does not change other files in the directory. Your own skills stay as they are. The command lists each new file and each updated file. When a new version of the gem removes a file, the CHANGELOG names that file. import does not delete it. You must delete it. To update the skills after a new version of the gem: 1. Run bundle update agent primitives . 2. Run bundle exec agent primitives import