principles 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +151 -1
- data/README.md +10 -6
- data/exe/principles +1 -1
- data/lib/principles/cli.rb +9 -10
- data/lib/principles/command_line.rb +15 -6
- data/lib/principles/command_routes.rb +18 -2
- data/lib/principles/controllers/acknowledgement.rb +19 -4
- data/lib/principles/controllers/acknowledgements.rb +43 -12
- data/lib/principles/controllers/after_commit_report.rb +15 -2
- data/lib/principles/controllers/assessment.rb +7 -3
- data/lib/principles/controllers/audit.rb +17 -8
- data/lib/principles/controllers/audit_completion.rb +34 -9
- data/lib/principles/controllers/carrier_edit_report.rb +40 -0
- data/lib/principles/controllers/carrier_practices.rb +26 -0
- data/lib/principles/controllers/command.rb +36 -5
- data/lib/principles/controllers/context_budget.rb +61 -0
- data/lib/principles/controllers/correction.rb +15 -5
- data/lib/principles/controllers/full_audit_request.rb +38 -42
- data/lib/principles/controllers/inventory.rb +78 -71
- data/lib/principles/controllers/last_record_notice_beside.rb +51 -0
- data/lib/principles/controllers/member_addition.rb +20 -5
- data/lib/principles/controllers/member_entries.rb +50 -39
- data/lib/principles/controllers/member_entry_changes.rb +71 -0
- data/lib/principles/controllers/member_problems_report.rb +26 -6
- data/lib/principles/controllers/members_a_commit_changed.rb +14 -5
- data/lib/principles/controllers/members_in_logged_requests.rb +52 -0
- data/lib/principles/controllers/members_to_assess.rb +35 -8
- data/lib/principles/controllers/meta_principle_setup.rb +12 -4
- data/lib/principles/controllers/open_correction.rb +3 -2
- data/lib/principles/controllers/parts_to_read.rb +48 -6
- data/lib/principles/controllers/plugin_member_addition.rb +48 -0
- data/lib/principles/controllers/principle_listing.rb +84 -0
- data/lib/principles/controllers/request_logging.rb +65 -0
- data/lib/principles/controllers/running_tool.rb +55 -15
- data/lib/principles/controllers/session_start_report.rb +26 -2
- data/lib/principles/data/branches_bringing_in.rb +52 -0
- data/lib/principles/data/captured_requests.rb +118 -0
- data/lib/principles/data/carrier_page_markers.rb +38 -0
- data/lib/principles/data/changes_since.rb +56 -0
- data/lib/principles/data/claude_code_home.rb +75 -0
- data/lib/principles/data/command-steps.json +139 -23
- data/lib/principles/data/decoded_leaf.rb +63 -0
- data/lib/principles/data/head_reflog.rb +13 -2
- data/lib/principles/data/kept_line.rb +39 -0
- data/lib/principles/data/known_marketplaces.rb +50 -0
- data/lib/principles/data/logged_request_matches.rb +144 -0
- data/lib/principles/data/logged_request_scan.rb +188 -0
- data/lib/principles/data/map_files.rb +18 -4
- data/lib/principles/data/plugin_folder.rb +85 -0
- data/lib/principles/data/plugin_registry.rb +73 -0
- data/lib/principles/data/principles_store.rb +49 -0
- data/lib/principles/data/project_files.rb +15 -0
- data/lib/principles/data/ran.rb +25 -0
- data/lib/principles/data/raw_request_filter.rb +61 -0
- data/lib/principles/data/repository.rb +29 -27
- data/lib/principles/data/request_logging_folder.rb +135 -0
- data/lib/principles/data/request_shape.rb +33 -0
- data/lib/principles/data/running_version.rb +1 -1
- data/lib/principles/data/schemas/acknowledgement-answer.schema.json +16 -1
- data/lib/principles/data/schemas/acknowledgements-answer.schema.json +16 -1
- data/lib/principles/data/schemas/assessment-answer.schema.json +8 -0
- data/lib/principles/data/schemas/command-steps.schema.json +1 -1
- data/lib/principles/data/schemas/correction-answer-guide.schema.json +2 -1
- data/lib/principles/data/schemas/correction-answer.schema.json +14 -0
- data/lib/principles/data/schemas/member-map.schema.json +12 -1
- data/lib/principles/data/settings_env_keys.rb +26 -0
- data/lib/principles/data/string_counts.rb +39 -0
- data/lib/principles/data/tools_on_path.rb +25 -0
- data/lib/principles/data/user_request_logging_folder.rb +73 -0
- data/lib/principles/invocation_options.rb +5 -3
- data/lib/principles/launch.rb +29 -10
- data/lib/principles/models/acknowledged_check.rb +11 -1
- data/lib/principles/models/acknowledgement.rb +5 -0
- data/lib/principles/models/acknowledgement_refusal.rb +20 -11
- data/lib/principles/models/acknowledgements_to_offer.rb +86 -0
- data/lib/principles/models/after_commit_input.rb +5 -0
- data/lib/principles/models/answer_fields.rb +3 -0
- data/lib/principles/models/assessment_basis.rb +10 -3
- data/lib/principles/models/audit.rb +10 -10
- data/lib/principles/models/audit_record.rb +10 -0
- data/lib/principles/models/audit_records.rb +4 -3
- data/lib/principles/models/audit_start.rb +9 -0
- data/lib/principles/models/authored_locator.rb +33 -0
- data/lib/principles/models/candidate_files.rb +23 -3
- data/lib/principles/models/candidate_outline.rb +18 -125
- data/lib/principles/models/captured_sessions.rb +166 -0
- data/lib/principles/models/carrier_edit_input.rb +56 -0
- data/lib/principles/models/carrier_kind.rb +79 -0
- data/lib/principles/models/carrier_pages_shown.rb +28 -0
- data/lib/principles/models/carved_message_bytes.rb +115 -0
- data/lib/principles/models/cited_files.rb +12 -3
- data/lib/principles/models/context_parts.rb +59 -0
- data/lib/principles/models/decided_prior_findings.rb +5 -0
- data/lib/principles/models/declared_map_changes.rb +22 -13
- data/lib/principles/models/disposition.rb +37 -6
- data/lib/principles/models/disposition_placeholders.rb +12 -0
- data/lib/principles/models/disposition_text_field.rb +4 -0
- data/lib/principles/models/dropped_thinking.rb +73 -0
- data/lib/principles/models/feature.rb +54 -0
- data/lib/principles/models/finding_outcomes.rb +55 -0
- data/lib/principles/models/findings_left_open.rb +9 -11
- data/lib/principles/models/head_moves.rb +27 -10
- data/lib/principles/models/installed_component.rb +55 -0
- data/lib/principles/models/installed_plugins.rb +174 -0
- data/lib/principles/models/kept_sessions.rb +34 -0
- data/lib/principles/models/locator.rb +8 -0
- data/lib/principles/models/logged_request_reach.rb +52 -0
- data/lib/principles/models/logged_request_scan_completeness.rb +43 -0
- data/lib/principles/models/map_format_raise.rb +28 -0
- data/lib/principles/models/mapped_baseline.rb +46 -0
- data/lib/principles/models/mapped_principles.rb +2 -1
- data/lib/principles/models/maps_holding_file_whole.rb +42 -0
- data/lib/principles/models/markdown_text.rb +143 -0
- data/lib/principles/models/member.rb +19 -1
- data/lib/principles/models/member_entry.rb +56 -0
- data/lib/principles/models/member_justification.rb +52 -0
- data/lib/principles/models/member_lines.rb +11 -0
- data/lib/principles/models/member_loads.rb +17 -2
- data/lib/principles/models/member_problems.rb +46 -42
- data/lib/principles/models/member_reach.rb +59 -0
- data/lib/principles/models/member_snapshots.rb +34 -4
- data/lib/principles/models/member_text_as_sent.rb +31 -0
- data/lib/principles/models/member_texts.rb +45 -0
- data/lib/principles/models/members_by_part.rb +67 -0
- data/lib/principles/models/members_in_logged_requests.rb +279 -0
- data/lib/principles/models/meta_principle.rb +4 -4
- data/lib/principles/models/missing_files.rb +41 -16
- data/lib/principles/models/nearly_matching_maps.rb +56 -0
- data/lib/principles/models/open_correction.rb +5 -0
- data/lib/principles/models/open_finding.rb +4 -3
- data/lib/principles/models/outline_budget.rb +10 -1
- data/lib/principles/models/outline_item.rb +25 -0
- data/lib/principles/models/outline_section.rb +15 -4
- data/lib/principles/models/part_named.rb +16 -2
- data/lib/principles/models/part_token_estimates.rb +60 -0
- data/lib/principles/models/plugin_component.rb +37 -0
- data/lib/principles/models/plugin_enabled_in_project_settings.rb +61 -0
- data/lib/principles/models/plugin_install.rb +33 -0
- data/lib/principles/models/plugin_name.rb +23 -0
- data/lib/principles/models/plugin_reference.rb +53 -0
- data/lib/principles/models/principle.rb +7 -4
- data/lib/principles/models/principle_members.rb +22 -0
- data/lib/principles/models/prior_finding_decision.rb +1 -1
- data/lib/principles/models/prior_finding_outcomes.rb +12 -1
- data/lib/principles/models/problem_report.rb +14 -25
- data/lib/principles/models/project.rb +51 -56
- data/lib/principles/models/project_harness.rb +48 -0
- data/lib/principles/models/project_history.rb +19 -5
- data/lib/principles/models/recorded_members.rb +7 -0
- data/lib/principles/models/report_hooks.rb +9 -4
- data/lib/principles/models/request_channel.rb +62 -0
- data/lib/principles/models/request_kind.rb +62 -0
- data/lib/principles/models/request_logging.rb +231 -0
- data/lib/principles/models/request_logging_guard.rb +84 -0
- data/lib/principles/models/request_time.rb +46 -0
- data/lib/principles/models/runs_from.rb +0 -5
- data/lib/principles/models/script_comments.rb +58 -0
- data/lib/principles/models/session_registry.rb +61 -0
- data/lib/principles/models/session_start_input.rb +11 -2
- data/lib/principles/models/session_trend.rb +36 -0
- data/lib/principles/models/stale_request.rb +9 -0
- data/lib/principles/models/turn_opening.rb +83 -0
- data/lib/principles/models/turn_position.rb +43 -0
- data/lib/principles/models/unfixed_part.rb +82 -0
- data/lib/principles/models/unresolved_plugin_members.rb +35 -0
- data/lib/principles/models/user_logged_requests.rb +90 -0
- data/lib/principles/models/user_settings_entries.rb +49 -0
- data/lib/principles/models/whole_file_member_read.rb +48 -0
- data/lib/principles/models/without_prose.rb +20 -0
- data/lib/principles/models/workflow_jobs.rb +92 -0
- data/lib/principles/show_members_in_logged_requests_options.rb +27 -0
- data/lib/principles/show_principle_options.rb +32 -0
- data/lib/principles/version.rb +2 -2
- data/lib/principles/views/acknowledged_result.rb +31 -12
- data/lib/principles/views/acknowledgement_result.rb +18 -13
- data/lib/principles/views/acknowledgement_template_alone.rb +55 -0
- data/lib/principles/views/acknowledgements_offered.rb +54 -0
- data/lib/principles/views/added_member.rb +22 -6
- data/lib/principles/views/answer_in_a_file.rb +15 -15
- data/lib/principles/views/assessed_members.rb +19 -8
- data/lib/principles/views/assessment_request.rb +14 -6
- data/lib/principles/views/audit_changes.rb +14 -8
- data/lib/principles/views/audit_findings.rb +34 -0
- data/lib/principles/views/audit_result.rb +26 -24
- data/lib/principles/views/candidate_files_result.rb +1 -1
- data/lib/principles/views/carrier_checks.rb +40 -0
- data/lib/principles/views/carrier_edit_denial.rb +36 -0
- data/lib/principles/views/carrier_practices_page.rb +49 -0
- data/lib/principles/views/completed_audit_findings.rb +33 -0
- data/lib/principles/views/completed_audit_next_step.rb +12 -4
- data/lib/principles/views/consecutive_sections_elsewhere.rb +4 -0
- data/lib/principles/views/context_budget_result.rb +99 -0
- data/lib/principles/views/context_parts.rb +129 -25
- data/lib/principles/views/correction_request.rb +32 -17
- data/lib/principles/views/disposition_template.rb +35 -0
- data/lib/principles/views/first_audit.rb +29 -15
- data/lib/principles/views/first_audit_line.rb +4 -5
- data/lib/principles/views/hook_setup_result.rb +3 -1
- data/lib/principles/views/invocation.rb +14 -5
- data/lib/principles/views/last_record_notice.rb +41 -0
- data/lib/principles/views/lines_shared_with_member.rb +16 -22
- data/lib/principles/views/logged_request_status_meanings.rb +29 -0
- data/lib/principles/views/logged_requests_evidence.rb +84 -0
- data/lib/principles/views/map_added_to.rb +14 -12
- data/lib/principles/views/map_format_raised.rb +28 -0
- data/lib/principles/views/map_result.rb +41 -18
- data/lib/principles/views/maps_needing_members_or_audit.rb +1 -1
- data/lib/principles/views/member_change_since_baseline.rb +4 -0
- data/lib/principles/views/member_row.rb +13 -4
- data/lib/principles/views/member_sets_overlap.rb +31 -0
- data/lib/principles/views/members_a_commit_changed.rb +42 -25
- data/lib/principles/views/members_changed_during_audit.rb +27 -0
- data/lib/principles/views/members_in_logged_requests_result.rb +123 -0
- data/lib/principles/views/members_too_short_to_scan.rb +45 -0
- data/lib/principles/views/members_with_no_baseline.rb +6 -6
- data/lib/principles/views/meta_principle_result.rb +52 -15
- data/lib/principles/views/open_findings_line.rb +31 -92
- data/lib/principles/views/parts_index_result.rb +9 -5
- data/lib/principles/views/principle_read_result.rb +52 -11
- data/lib/principles/views/prior_findings_result.rb +9 -1
- data/lib/principles/views/problem_facts.rb +5 -3
- data/lib/principles/views/problem_lines.rb +54 -6
- data/lib/principles/views/problem_result.rb +7 -15
- data/lib/principles/views/prompts/assess-every-member/ask-whether-a-member-seen-only-as-read-is-loaded.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/ask-whether-each-reason-holds.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/claim-an-earlier-first-raised-at.md +6 -6
- data/lib/principles/views/prompts/assess-every-member/judge-the-keeping-against-the-other-principles.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-compact-carried-member.md +9 -8
- data/lib/principles/views/prompts/assess-every-member/read-a-flagged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/read-a-judged-member-s-text-whole.md +3 -0
- data/lib/principles/views/prompts/assess-every-member/turn-on-request-logging-to-see-what-reaches-context.md +2 -0
- data/lib/principles/views/prompts/assess-every-member/weigh-what-reached-the-context.md +7 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/answer-guide.json +1 -0
- data/lib/principles/views/prompts/dispose-of-each-finding/fix-or-record-each-finding.md +6 -1
- data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md +1 -0
- data/lib/principles/views/prompts/edit-a-carrier/read-the-page-before-the-first-edit.md +2 -0
- data/lib/principles/views/prompts/find-a-principle-to-map/read-a-cut-section-back.md +1 -1
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-configuration.md +41 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-instruction-files.md +37 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-other-text-an-agent-reads.md +38 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md +34 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-skills.md +35 -0
- data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-subagent-definitions.md +35 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/add-member.md +49 -51
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-name.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-reason.md +12 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/change-member-role.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/every-command-and-how-they-chain.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-candidate-files.md +1 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/list-member-problems.md +32 -32
- data/lib/principles/views/prompts/learn-what-a-command-does/list-open-findings.md +10 -11
- data/lib/principles/views/prompts/learn-what-a-command-does/move-member.md +7 -6
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-logged-requests.md +22 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/remove-member.md +2 -1
- data/lib/principles/views/prompts/learn-what-a-command-does/report-at-session-start.md +8 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/report-before-carrier-edit.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-audit.md +7 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-candidate-outlines.md +8 -2
- data/lib/principles/views/prompts/learn-what-a-command-does/show-carrier-practices.md +13 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-context-budget.md +69 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-hook-setup.md +4 -4
- data/lib/principles/views/prompts/learn-what-a-command-does/show-logged-requests.md +22 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-members-in-logged-requests.md +62 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/show-meta-principle-passage.md +13 -10
- data/lib/principles/views/prompts/learn-what-a-command-does/show-principle.md +16 -16
- data/lib/principles/views/prompts/learn-what-a-command-does/start-audit.md +27 -27
- data/lib/principles/views/prompts/learn-what-a-command-does/submit-answer.md +17 -17
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-off-request-logging.md +18 -0
- data/lib/principles/views/prompts/learn-what-a-command-does/turn-on-request-logging.md +44 -0
- data/lib/principles/views/prompts/read-requested-outlines/continue-the-survey.md +3 -2
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-request-logging-to-the-user.md +11 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/explain-user-request-logging-to-the-user.md +10 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/see-whether-members-reach-the-agent.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-a-thread-continuation-holds.md +3 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-absent-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-each-context-budget-line-says.md +4 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-each-member-line-says.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-not-a-carrier-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-but-not-loaded-means.md +2 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-present-means.md +1 -0
- data/lib/principles/views/prompts/read-what-reached-the-context/what-unmeasurable-means.md +2 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/a-row-ending-pinned-asks-for-an-audit.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/plugin-members-are-still-listed.md +1 -0
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members-waiting-on-an-upgrade.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/the-commits-changed-these-members.md +2 -2
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-what-each-needs-before-the-next-commit.md +1 -0
- data/lib/principles/views/prompts/run-a-first-audit-in-the-background/follow-the-brief.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/ask-to-set-principles-up-after-an-audit.md +1 -0
- data/lib/principles/views/prompts/set-principles-up/entry-file-passage.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/map-the-enabling-line-at-no-edit.md +3 -0
- data/lib/principles/views/prompts/set-principles-up/name-the-step-each-member-lacks.md +2 -2
- data/lib/principles/views/prompts/set-principles-up/place-the-passage-with-the-user.md +4 -2
- data/lib/principles/views/prompts/set-principles-up/what-the-passage-presumes.md +1 -1
- data/lib/principles/views/prompts/set-principles-up/why-set-principles-up.md +1 -0
- data/lib/principles/views/prompts/start-a-session/act-on-the-open-findings.md +2 -1
- data/lib/principles/views/prompts/start-a-session/ask-to-set-principles-up.md +2 -0
- data/lib/principles/views/prompts/start-a-session/hand-the-first-audit-to-a-subagent.md +2 -3
- data/lib/principles/views/prompts/start-a-session/name-the-principles-nothing-checks.md +1 -0
- data/lib/principles/views/prompts/start-a-session/raise-the-open-findings-waiting-on-no-one.md +1 -0
- data/lib/principles/views/request_logging_result.rb +108 -0
- data/lib/principles/views/request_part.rb +10 -4
- data/lib/principles/views/request_parts.rb +9 -0
- data/lib/principles/views/set_up_offer_line.rb +43 -0
- data/lib/principles/views/whole_file_elsewhere.rb +30 -0
- metadata +154 -5
- data/lib/principles/views/prompts/report-after-a-commit/the-principles-skill-is-where-to-start.md +0 -1
- data/lib/principles/views/prompts/report-after-a-commit/this-command-shows-each-one.md +0 -1
- data/lib/principles/views/prompts/set-principles-up/keep-them-held-between-audits.md +0 -2
|
@@ -13,9 +13,9 @@ module Principles
|
|
|
13
13
|
Lines = Struct.new(:stdout, :stderr, :status, keyword_init: true)
|
|
14
14
|
|
|
15
15
|
# list-member-problems --short, for a commit hook or heartbeat that acts on an exit status and short lines
|
|
16
|
-
# alone: one tab-separated line per changed member on stdout, then one per
|
|
17
|
-
#
|
|
18
|
-
# anything an empty stdout would hide.
|
|
16
|
+
# alone: one tab-separated line per changed member on stdout, then one per plugin member no installed plugin
|
|
17
|
+
# gives, then one per principle counting its members no audit has assessed, exit 3 when a changed member's row
|
|
18
|
+
# or a count asks for action, and on stderr what to do next and anything an empty stdout would hide.
|
|
19
19
|
class ProblemLines
|
|
20
20
|
# The exit status that says a member's own text changed since an audit or acknowledgement assessed it, or that
|
|
21
21
|
# no audit has assessed a member; 1 and 2 already mean refused and usage error.
|
|
@@ -36,13 +36,34 @@ module Principles
|
|
|
36
36
|
#: (Hash[String, untyped], nothing_changed: String, assessed_change: bool,
|
|
37
37
|
#| never_assessed: Hash[String, Integer], names_a_command: bool) -> Lines
|
|
38
38
|
def short(report, nothing_changed:, assessed_change:, never_assessed:, names_a_command:)
|
|
39
|
-
rows
|
|
40
|
-
never_assessed.map { |id, count| counted(id, count) }
|
|
41
|
-
Lines.new(stdout: rows.map { "#{it}\n" }.join,
|
|
39
|
+
Lines.new(stdout: rows(report, never_assessed).map { "#{it}\n" }.join,
|
|
42
40
|
stderr: notes(report, nothing_changed, names_a_command).map { |note| "#{note}\n" }.join,
|
|
43
41
|
status: assessed_change || !never_assessed.empty? ? CHANGED : 0)
|
|
44
42
|
end
|
|
45
43
|
|
|
44
|
+
# short's lines, or when they are empty, one stderr line saying nothing changed among members, so an agent can
|
|
45
|
+
# tell a clean project from a run that printed nothing; stdout stays empty for a trigger acting on its rows. The
|
|
46
|
+
# session-start lines never carry it, since that output is spent in every session.
|
|
47
|
+
#: (Lines, members: Integer) -> Lines
|
|
48
|
+
def saying_nothing_changed(short, members:)
|
|
49
|
+
return short unless short.stdout.empty? && short.stderr.empty?
|
|
50
|
+
|
|
51
|
+
Lines.new(stdout: "", stderr: "Nothing changed (#{members} member#{"s" unless members == 1}).\n",
|
|
52
|
+
status: short.status)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# short's lines with one stderr line first saying what each last field its changed members' rows end with asks
|
|
56
|
+
# for, so an agent can tell an acknowledgement from an audit; unchanged when no row does. A row waiting
|
|
57
|
+
# on an upgrade asks nothing yet, as stderr's update sentence says.
|
|
58
|
+
#: (Lines, Hash[String, untyped]) -> Lines
|
|
59
|
+
def explaining_rows(short, report)
|
|
60
|
+
ending = report.fetch("members").reject { it["waiting_on_an_upgrade"] }.map { it.dig("since", "baseline") }
|
|
61
|
+
asks = ending.uniq.filter_map { row_asks(it) }
|
|
62
|
+
return short if asks.empty?
|
|
63
|
+
|
|
64
|
+
Lines.new(stdout: short.stdout, stderr: "#{asks.join(" ")}\n#{short.stderr}", status: short.status)
|
|
65
|
+
end
|
|
66
|
+
|
|
46
67
|
# short's lines for a session-start hook: on stdout, one line for each principle with a changed member an
|
|
47
68
|
# audit or acknowledgement assessed, as session_start_lines says, from changed, in place of the rows and
|
|
48
69
|
# never-assessed counts, which an always-loaded carrier cannot afford; stderr and the status kept.
|
|
@@ -67,6 +88,33 @@ module Principles
|
|
|
67
88
|
|
|
68
89
|
private
|
|
69
90
|
|
|
91
|
+
# short's stdout rows: each changed member's, then each plugin member's no installed plugin gives, then each
|
|
92
|
+
# principle's count of members no audit has assessed.
|
|
93
|
+
#: (Hash[String, untyped], Hash[String, Integer]) -> Array[String]
|
|
94
|
+
def rows(report, never_assessed)
|
|
95
|
+
report.fetch("members").map { MemberRow.new(it).short } +
|
|
96
|
+
report.fetch("plugin_unresolved", []).map { unresolved(it) } +
|
|
97
|
+
never_assessed.map { |id, count| counted(id, count) }
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# The row of a plugin member no installed plugin gives, in a changed member's fields: its principle, id, that it
|
|
101
|
+
# is unresolved and why. It moves no count or exit status: a session without the plugin has nothing to act on.
|
|
102
|
+
#: (Hash[String, untyped]) -> String
|
|
103
|
+
def unresolved(member)
|
|
104
|
+
[member.fetch("principle"), member.fetch("id"), "plugin_unresolved", member.fetch("reason")]
|
|
105
|
+
.map { VisibleText.new(it).to_s }.join("\t")
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# What a row whose last field names baseline asks for, in the order the rows give.
|
|
109
|
+
#: (String) -> String?
|
|
110
|
+
def row_asks(baseline)
|
|
111
|
+
case baseline
|
|
112
|
+
when "audit" then Prompts.text("report-after-a-commit/a-row-ending-audit-asks-to-acknowledge-or-audit-again")
|
|
113
|
+
when "mapping_commit" then Prompts.text("report-after-a-commit/a-row-ending-mapping-commit-asks-for-an-audit")
|
|
114
|
+
when "pinned" then Prompts.text("report-after-a-commit/a-row-ending-pinned-asks-for-an-audit")
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
70
118
|
# The session-start line on principle id's count of changed audited members.
|
|
71
119
|
#: (String, Integer) -> String
|
|
72
120
|
def changed_line(id, count)
|
|
@@ -116,26 +116,18 @@ module Principles
|
|
|
116
116
|
# names members a one-member audit may judge, one acknowledgement for all of them, filled and shell-quoted so
|
|
117
117
|
# the agent types no id, after one lead saying when to audit in full instead; the full audit for a principle
|
|
118
118
|
# with a changed member no acknowledgement may judge, with no condition, as nothing else applies to it. None for
|
|
119
|
-
# a principle in waits, whose audits wait on an upgrade
|
|
120
|
-
|
|
119
|
+
# a principle in waits, whose audits wait on an upgrade, nor one awaiting its first full audit, whose audit
|
|
120
|
+
# unaudited_action names already.
|
|
121
|
+
#: (Hash[String, untyped], AcknowledgementsOffered, Array[String]) -> String?
|
|
121
122
|
def changed_action(report, acknowledgeable, waits)
|
|
122
|
-
changed = report.fetch("members").group_by { it.fetch("principle") }
|
|
123
|
-
|
|
124
|
-
full = changed.filter_map { |id, members| full_audit_line(id, members,
|
|
123
|
+
changed = report.fetch("members").group_by { it.fetch("principle") }
|
|
124
|
+
.except(*waits, *report.fetch("awaiting_first_audit", []))
|
|
125
|
+
full = changed.filter_map { |id, members| full_audit_line(id, members, acknowledgeable.members_of(id)) }
|
|
126
|
+
acknowledging = acknowledgeable.lines(@invocation)
|
|
125
127
|
lines = [*(ACKNOWLEDGE_LEAD unless acknowledging.empty?), *acknowledging, *full]
|
|
126
128
|
lines.empty? ? nil : lines.join("\n")
|
|
127
129
|
end
|
|
128
130
|
|
|
129
|
-
# The acknowledgement of every member in members by the principles ids names, each of those it maps.
|
|
130
|
-
#: (Array[String], Array[String]) -> String
|
|
131
|
-
def acknowledge_line(ids, members)
|
|
132
|
-
@invocation.listed_in_project("start-audit", ids, options: members.flat_map { ["--member", it] })
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# The members an acknowledgement in acknowledgeable takes in for principle id.
|
|
136
|
-
#: (Hash[Array[String], Array[String]], String) -> Array[String]
|
|
137
|
-
def acknowledged_in(acknowledgeable, id) = acknowledgeable.select { |ids, _| ids.include?(id) }.values.flatten
|
|
138
|
-
|
|
139
131
|
# The full audit of principle id, for its changed members no acknowledgement may judge, or nil when the
|
|
140
132
|
# acknowledgement takes in every one.
|
|
141
133
|
#: (String, Array[Hash[String, untyped]], Array[String]) -> String?
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
A finding kept from records written before this tool kept `first_raised_at` is dated late. When the record's git
|
|
2
|
-
history shows an earlier version leaving it open, at `.principles/audits/` or
|
|
3
|
-
`.memeplex/audits/`, and you judge it the same finding, give `first_raised_at`, that
|
|
4
|
-
`raised_in`, the full sha of the commit holding it, in its `still_holds` decision. This
|
|
5
|
-
that commit only, and refuses the claim unless that version leaves a finding with the same
|
|
6
|
-
its `audited_at` equals the claimed time, and the time is earlier than the one stored;
|
|
7
|
-
finding is yours to judge.
|
|
2
|
+
history, which `git log --follow` on it lists, shows an earlier version leaving it open, at `.principles/audits/` or
|
|
3
|
+
the folder's earlier name `.memeplex/audits/`, and you judge it the same finding, give `first_raised_at`, that
|
|
4
|
+
version's `audited_at`, with `raised_in`, the full sha of the commit holding it, in its `still_holds` decision. This
|
|
5
|
+
tool reads the record at that commit only, and refuses the claim unless that version leaves a finding with the same
|
|
6
|
+
id deferred or accepted, its `audited_at` equals the claimed time, and the time is earlier than the one stored;
|
|
7
|
+
whether it is the same finding is yours to judge.
|
|
@@ -5,3 +5,5 @@ last judged them. This principle's members are what is meant to bring such chang
|
|
|
5
5
|
listed change against them: where one has waited with nothing in the project carrying the step that would have
|
|
6
6
|
caught it, raise a finding on the member that should carry it. Each listed principle's own audit judges its
|
|
7
7
|
change; this one does not.
|
|
8
|
+
Weigh, too, whether each member here is in context when its work is in hand and out of it otherwise, so usable
|
|
9
|
+
context stays as large as it can.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
When judging the set needs what a carried member was judged to say, run `show-audit` with this principle's id
|
|
2
|
-
|
|
3
|
-
any check, whose `check_result` its template still asks for, unless one of those facts fires: then
|
|
4
|
-
its stored assessment and evidence. It prints whole when `evidence_changed` or
|
|
5
|
-
when a `mapped_elsewhere` entry names `open_finding_ids`, and when this principle
|
|
6
|
-
`open_finding_ids` names that finding, the same one the prior findings list. An
|
|
7
|
-
since it says how old its sighting is: judge the member again when that
|
|
8
|
-
marker with a fresh assessment whenever you no longer stand behind the
|
|
1
|
+
When judging the set needs what a carried member was judged to say, run `show-audit` with this principle's id, which
|
|
2
|
+
prints that member's stored assessment. A carried member here shows only its `assessed_at`, the facts that say what
|
|
3
|
+
moved around it, and any check, whose `check_result` its template still asks for, unless one of those facts fires: then
|
|
4
|
+
it prints whole, with its stored assessment and evidence. It prints whole when `evidence_changed` or
|
|
5
|
+
`file_changed_outside_member` is true, when a `mapped_elsewhere` entry names `open_finding_ids`, and when this principle
|
|
6
|
+
leaves a finding open on it: its `open_finding_ids` names that finding, the same one the prior findings list. An
|
|
7
|
+
observed delivery's `observed_at` stays, since it says how old its sighting is: judge the member again when that
|
|
8
|
+
sighting is too old to stand behind. Replace a marker with a fresh assessment whenever you no longer stand behind the
|
|
9
|
+
one carried.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
A fact fires on this carried member, so decide whether to judge it again. If you judge it again, run `read_with` and
|
|
2
|
+
read its text whole as a step of that judgement, starting from its evidence and its `mapped_elsewhere` passages: a line
|
|
3
|
+
a change elsewhere left stale shows in no diff.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
Run `read_with` and read this member's text whole, as a step of judging it, not an extra: a line a change elsewhere
|
|
2
|
+
left stale shows in no diff. Start from its last assessment's evidence and its `mapped_elsewhere` passages, then ask
|
|
3
|
+
whether the whole member still carries this principle.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Weigh what reached the context. `members` lists every member this request lists, those marked `carried_forward`
|
|
2
|
+
too, whose text has not changed since the last audit but may still never reach the agent. `seen_in` counts the
|
|
3
|
+
captured requests that held a member's lines, of the `requests` beside `members`, every captured request the scan
|
|
4
|
+
read through, `channels` counts them by the channel it came by, and `most_bytes` is the most of them one request held; `unreadable`, when printed, counts requests that
|
|
5
|
+
could not be read. `detail_with` shows where one member was seen, given its `member` as KEY. Did a member seen in no request carry its principle to the agent at all? `seen_only_as_read`, when printed, lists the members seen in no channel the host loads by, under one question. Is a member seen in every
|
|
6
|
+
request worth its bytes in every session? Say so in the member's assessment where it changes your judgement, and for
|
|
7
|
+
a carried member in `collective_assessment`.
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"action": "fixed",
|
|
5
5
|
"reason": "What you changed, in one line",
|
|
6
6
|
"changed_members": ["the id of each member the fix changed"],
|
|
7
|
+
"changed_map_entries": ["the id of each member whose role, check, name or reason the fix changed"],
|
|
7
8
|
"removed_members": ["the id of each member the fix removed from the map"],
|
|
8
9
|
"evidence": [{ "path": "a project file", "starting_at": "text that occurs once in the fixed passage" }],
|
|
9
10
|
"reassessment": "How the changed member reads now, and any check you ran on it",
|
|
@@ -11,12 +11,17 @@ or a notes file, set its `recorded_at` to that place, as `{"path": ..., "heading
|
|
|
11
11
|
When a deferral waits on someone, set its `waits_on` to one line saying whom it waits on and to decide what, such as
|
|
12
12
|
"<person>, to approve a CI change", and keep the reason in the write-up. Leave it null when it waits on no one in
|
|
13
13
|
particular. Only a deferral may give one, and this tool records when it was asked.
|
|
14
|
+
If a fix settles only part of a finding, keep it fixed and give the rest as its `unfixed_part`, rather than deferring
|
|
15
|
+
the whole finding:
|
|
16
|
+
`{"id": NEW_ID, "problem": ..., "action": "deferred", "reason": ..., "recorded_at": ..., "waits_on": ...}`, or
|
|
17
|
+
`"action": "accepted"`. The record keeps the finding fixed and raises that part as a new finding of the same members,
|
|
18
|
+
under an id no other finding has.
|
|
14
19
|
If a fix rewrites the heading or the quoted text that locates a member, or the member's passage should be narrower
|
|
15
20
|
or wider, move the member with `move-member`, then list the move in the answer as
|
|
16
21
|
`"moved_members": [{"from": OLD_ID, "to": NEW_ID}]`, or `[{"from": ID, "to": ID}]` when the move kept its id, and
|
|
17
22
|
name the id after the move in the finding's `changed_members`. In git, the move is checked against the map
|
|
18
23
|
the audit began from.
|
|
19
|
-
If the fix is to a member's role or
|
|
24
|
+
If the fix is to a member's role, check, name or reason in the map, make it with that field's `change-member-` command
|
|
20
25
|
and list the member's id in the finding's `changed_map_entries`. In git, the change is checked against the map the
|
|
21
26
|
audit began from.
|
|
22
27
|
If the fix is to map a member the finding says is missing, add it with `add-member` and name its id in the finding's
|
data/lib/principles/views/prompts/dispose-of-each-finding/read-the-carrier-page-before-fixing.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Before you fix a member, read its carrier kind's page with `carrier_checks.page_command`, its last word that kind, and follow it.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
To keep this result short, the list items of each file under inventory.outlines_cut are cut: under each of
|
|
2
|
-
its headings, `(N more, lines A-B)` says how many items
|
|
2
|
+
its headings, `(N more, lines A-B)` says how many items it leaves out and which lines of the file hold them. Where
|
|
3
3
|
the survey needs a cut section's items, read just those lines of the file, not the whole file.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Hook configuration: the right event and matcher, and output the agent needs
|
|
2
|
+
|
|
3
|
+
A hook entry decides when a command runs and whether its output reaches the
|
|
4
|
+
agent. Ask: does this event fire only when the work needs it, and is the matcher
|
|
5
|
+
as narrow as it can be? On a session-start or prompt event, is every byte it
|
|
6
|
+
prints worth paying for in every session? Is it a hook because the action must
|
|
7
|
+
always happen, not a preference? Does the command path resolve from any working
|
|
8
|
+
directory and worktree? Is it registered once?
|
|
9
|
+
|
|
10
|
+
## What reaches context, and when
|
|
11
|
+
- On session start and prompt submission, plain stdout and `additionalContext` are added as context the agent reads. Session start runs every session and after each compaction, so its output is an always-loaded carrier: keep it short, and put static text in the instructions file instead. (both)
|
|
12
|
+
- Output over the host's cap is saved to a file and the agent gets a preview. Do not rely on the agent reading the rest. (both)
|
|
13
|
+
- A pre-compaction hook's stdout instructs the summariser, not the agent; to brief the resumed agent, use session start with the `compact` source. (both)
|
|
14
|
+
- On other events, stdout on exit 0 is mostly not shown to the agent, and stderr on exit 0 never is. (Claude Code)
|
|
15
|
+
- Stop expects JSON on exit 0; plain text there is invalid. (Codex)
|
|
16
|
+
|
|
17
|
+
## Exit status and failure
|
|
18
|
+
- Exit 2 blocks on events that can block, with stderr as the reason. Exit 1 is a non-blocking error, not a block: a policy hook must exit 2. (Claude Code)
|
|
19
|
+
- On a pre-tool event, an error, timeout or malformed response can let the tool run. Treat tool hooks as a guardrail, not a complete boundary. (Codex)
|
|
20
|
+
- A failing hook fails open by default; opt into blocking on failure only where a missed check is worse than a stalled session. (Claude Code)
|
|
21
|
+
- A Stop hook that blocks keeps the agent working; a hook that cannot run there traps it. Make sure it can always start.
|
|
22
|
+
|
|
23
|
+
## Matchers and paths
|
|
24
|
+
- A matcher of plain names is exact; one with other characters is an unanchored regular expression, so `Edit.*` also matches other tools. Anchor with `^` and `$`. (Claude Code)
|
|
25
|
+
- Matchers are regular expressions, and some events ignore them. (Codex)
|
|
26
|
+
- Reference scripts from the project root variable. It stays at the main checkout when the session enters a worktree. (Claude Code)
|
|
27
|
+
- Commands run in the session's working directory, which may be a subdirectory; resolve scripts from the git root. (Codex)
|
|
28
|
+
- The same command registered in two files runs twice. Keep one format per layer. (Codex)
|
|
29
|
+
|
|
30
|
+
## Is a hook the right carrier
|
|
31
|
+
- A hook is right for what must happen every time: a block, a gate, a check. A preference belongs in instructions.
|
|
32
|
+
- Prompt and agent hooks ask another model, so they are not deterministic. (Claude Code)
|
|
33
|
+
- Codex parses prompt and agent handlers but skips them. (Codex)
|
|
34
|
+
- Project hooks must be reviewed and trusted before they run, and a changed hook is skipped until trusted again. (Codex)
|
|
35
|
+
- Hooks for an event run in parallel; one cannot stop another starting. (both)
|
|
36
|
+
- Never block compaction: blocked at the context limit, the request fails. (Claude Code)
|
|
37
|
+
- Command hooks time out after ten minutes by default, and prompt-submission hooks after 30 seconds. Set a short `timeout`: a slow hook stalls the session. (Claude Code)
|
|
38
|
+
|
|
39
|
+
Sources: [hooks reference](https://code.claude.com/docs/en/hooks),
|
|
40
|
+
[hooks guide](https://code.claude.com/docs/en/hooks-guide),
|
|
41
|
+
[Codex hooks](https://developers.openai.com/codex/hooks).
|
data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-hook-scripts.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Hook scripts: quiet, fast, deterministic, and safe when they fail
|
|
2
|
+
|
|
3
|
+
What a hook script prints may land in the agent's context, on every event it
|
|
4
|
+
matches. Ask: does it print nothing when there is nothing to act on? Is each
|
|
5
|
+
line it prints short, specific and actionable? Does it give the same output for
|
|
6
|
+
the same state, with no network or slow work in the hot path? Does its exit
|
|
7
|
+
status mean what the host reads it as, and what happens when it crashes, times
|
|
8
|
+
out or a tool it calls is missing?
|
|
9
|
+
|
|
10
|
+
## What it prints
|
|
11
|
+
- Silence is the default. A line printed when nothing needs doing teaches the agent to skim every later line.
|
|
12
|
+
- Print the fact and the next action, in one or two lines: the file, the check that failed, the command to run. Not a banner, a preamble or a restatement of the instructions file.
|
|
13
|
+
- On session start, every byte is paid in every session and again after each compaction. Point to a command or file the agent can read when needed rather than inlining a page. (both)
|
|
14
|
+
- Plain text and JSON are read differently. Print exactly one JSON object, with nothing else on stdout, or plain text, never a mix. (Claude Code)
|
|
15
|
+
- Diagnostics go to stderr or a log. On exit 0 the agent never sees stderr. (Claude Code)
|
|
16
|
+
- Never print secrets: oversized output is written to disk. (both)
|
|
17
|
+
|
|
18
|
+
## Exit status
|
|
19
|
+
- Exit 0 for success, including when the script chose to say nothing.
|
|
20
|
+
- Exit 2, with the reason on stderr, to block an action that can be blocked. Exit 1 does not block. (Claude Code)
|
|
21
|
+
- On a Stop event, a block tells the agent to keep working, using the reason as its next prompt. Make that reason a concrete task. (both)
|
|
22
|
+
|
|
23
|
+
## Determinism and speed
|
|
24
|
+
- Same input and state, same output. A script that varies by clock, randomness or network is hard to trust and harder to test.
|
|
25
|
+
- Session-start and prompt hooks block the session until they finish. Keep the work small, cache what is costly, and push slow or optional work to a background run whose output does not gate anything. (both)
|
|
26
|
+
- Read the event's JSON from stdin rather than guessing from the environment. Do not depend on the transcript's format; it is not a stable interface. (Codex)
|
|
27
|
+
|
|
28
|
+
## Failing safe
|
|
29
|
+
- Decide per script which way failure should fall. A reminder fails open and silent. A safety block should fail closed, but only if the script cannot trap the agent.
|
|
30
|
+
- Guard against a missing interpreter, a missing tool or a path from the wrong directory: resolve paths from the project root, check dependencies, and say plainly what is wrong in one line.
|
|
31
|
+
- With blocking on failure set, a crash on a Stop or completion event keeps the agent looping on a hook it cannot repair. Test that path. (Claude Code)
|
|
32
|
+
- Test the script by running the real trigger and reading what reached the agent, not only by running it by hand.
|
|
33
|
+
|
|
34
|
+
Sources: [hooks reference](https://code.claude.com/docs/en/hooks),
|
|
35
|
+
[Codex hooks](https://developers.openai.com/codex/hooks).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Instruction files: few lines, each owned once and checkable
|
|
2
|
+
|
|
3
|
+
A root file loads in every session, a nested one only for work in its folder,
|
|
4
|
+
so each line costs every task in its scope. Ask: would the agent err without
|
|
5
|
+
the line, or could it read this from the repository when needed? Does another
|
|
6
|
+
file own this rule, so this copy will drift? Does the line name something
|
|
7
|
+
checkable, a command, path or value, and say why? Does it belong here, or in a
|
|
8
|
+
scoped rule, a skill or one directory's own file? Does any line describe
|
|
9
|
+
something that no longer exists?
|
|
10
|
+
|
|
11
|
+
## What loads, and what it costs
|
|
12
|
+
- The root file, the local file, the user file and every rule file without `paths:` load at launch in every session, and the root and unscoped rules are re-read after compaction. (Claude Code)
|
|
13
|
+
- A nested `CLAUDE.md` loads only once the agent reads or edits a file in its directory, so it is the cheap home for one directory's facts. (Claude Code)
|
|
14
|
+
- Codex joins the `AGENTS.md` files from the project root down to the working directory once at start, later files winning, and stops at a byte cap. A nested file is not deferred there. (Codex)
|
|
15
|
+
- An `@` import is expanded into context with its parent: it organises a file but saves nothing. Mention a path in backticks to point at it without loading it. (Claude Code)
|
|
16
|
+
- Anthropic's target is under 200 lines per file. Count words as well: a few long lines can hide a large cost.
|
|
17
|
+
|
|
18
|
+
## Route each line by how it is used
|
|
19
|
+
- A fact or standing rule for every session goes in the root file. A topic for one part of the tree goes in a path-scoped rule. Steps you run in order belong in a skill or in a page a rule names. One piece of work's facts go in its working folder.
|
|
20
|
+
- Leave out what the agent learns by reading the code and would look up anyway. Keep exact commands, places where the code misleads, decisions the repository does not record, and anything corrected twice.
|
|
21
|
+
- Treat a new line as a displacement: find its home before finding room, and cut a line that outlived its subject first.
|
|
22
|
+
|
|
23
|
+
## Wording
|
|
24
|
+
- Give each rule one owner and link to it from elsewhere. Copies drift, and the agent settles a contradiction arbitrarily. Check that every link resolves.
|
|
25
|
+
- Name the checkable thing and the reason: "run `rake lint` before committing; CI rejects unformatted files" lets the agent judge cases the line never names, where "keep code tidy" gives it nothing to act on.
|
|
26
|
+
- Write the plain imperative. Attach to each "never" the case it covers and why. Capitals and stacked emphasis make current models over-apply a rule.
|
|
27
|
+
- Give one canonical example, not a catalogue of variants.
|
|
28
|
+
- If a rule may not be skipped, enforce it with a hook, a permission denial or a failing check. These files are advisory context, not enforcement.
|
|
29
|
+
|
|
30
|
+
## Keep it true
|
|
31
|
+
- Reconcile the instructions in the same change that renames, moves or retires what they describe. A stale line misleads every session.
|
|
32
|
+
- Put why a rule exists in the commit message that adds it, not in a maintainer note in the file.
|
|
33
|
+
- Confirm what actually loaded rather than assuming: the context view lists the memory files. (Claude Code)
|
|
34
|
+
|
|
35
|
+
Sources: [memory](https://code.claude.com/docs/en/memory),
|
|
36
|
+
[best practices](https://code.claude.com/docs/en/best-practices),
|
|
37
|
+
[AGENTS.md in Codex](https://developers.openai.com/codex/guides/agents-md).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Other text an agent reads: clear, minimal, checkable, at the right altitude
|
|
2
|
+
|
|
3
|
+
Judge this text by how it reaches the agent. If a program or hook puts it in
|
|
4
|
+
context in a way the path does not show, judge it as that carrier and apply its
|
|
5
|
+
practices. Then ask: does each line earn its place, leading with the action? Is
|
|
6
|
+
it pitched as a rule the agent can apply, neither a keystroke script nor a
|
|
7
|
+
platitude? Does each step end in evidence the agent can show? Does a rule that
|
|
8
|
+
must always hold have a mechanism, not louder words?
|
|
9
|
+
|
|
10
|
+
## How it loads decides what it costs
|
|
11
|
+
- A page the agent opens when a rule names it costs nothing until then. Keep it that way: point to it by path, and do not import or paste it into an always-loaded file.
|
|
12
|
+
- Text a program prints into context, such as a command's prompt or a monitor's message, is a carrier too. If it prints every session or on every tick, treat it as always-loaded: short, quiet when nothing needs doing, and pointing to a command for depth.
|
|
13
|
+
- A subagent sees only its brief and the files it loads. A step that hands work over puts everything needed in the brief. (Claude Code)
|
|
14
|
+
- After compaction, only the start of a long loaded body may survive. Put the instructions that hold throughout at the top. (Claude Code)
|
|
15
|
+
|
|
16
|
+
## Altitude and length
|
|
17
|
+
- Too low is a brittle list of exact commands that breaks when the setting differs. Too high is advice with no concrete signal. Aim for a rule and a discriminator the agent can apply to a case nobody foresaw.
|
|
18
|
+
- Current models need less: a brief instruction steers most behaviour. Text written for older models is often too prescriptive. (both)
|
|
19
|
+
- Minimal is not short. Keep what the agent needs to act; move the long why into the reference page the steps point to.
|
|
20
|
+
|
|
21
|
+
## Clarity
|
|
22
|
+
- Open with the action and its result; history can wait. Use numbered steps where order matters.
|
|
23
|
+
- Apply the colleague test: could a capable reader with only this text open carry it out?
|
|
24
|
+
- Use plain wording. Say what each "never" covers and why, so the agent can see when a case falls outside it. Stacked emphasis causes over-application.
|
|
25
|
+
- One canonical example teaches the pattern; a catalogue of variants teaches that everything is a special case.
|
|
26
|
+
|
|
27
|
+
## Verification
|
|
28
|
+
- End each step with a done-signal: a path that exists, a URL, an exit status, output to paste back. An instruction without one is easy to skip.
|
|
29
|
+
- Request proof and a brief summary, not a transcript of reasoning.
|
|
30
|
+
- Only a separate check confirms a claim, such as a fresh-context reviewer or a test run before and after, not by its author's account.
|
|
31
|
+
|
|
32
|
+
## Mechanism
|
|
33
|
+
- Text is weighed, not obeyed. A rule that must fire every time needs a hook, a permission denial or a build that fails without it. Another model's verdict informs a person; it does not gate the work.
|
|
34
|
+
- Corrected twice on the same rule, change the mechanism, not the sentence.
|
|
35
|
+
|
|
36
|
+
Sources: [best practices](https://code.claude.com/docs/en/best-practices),
|
|
37
|
+
[prompting best practices](https://platform.claude.com/docs/en/build-with-claude/prompt-engineering/claude-prompting-best-practices),
|
|
38
|
+
[context engineering](https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents).
|
data/lib/principles/views/prompts/follow-each-carriers-best-practices/practices-for-rule-files.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Rule files: one topic, scoped to the files it governs
|
|
2
|
+
|
|
3
|
+
A rule without `paths:` loads in every session like the root instructions, so
|
|
4
|
+
ask first whether it can be scoped. Does the file hold one topic, named in full
|
|
5
|
+
by its filename? Do its globs, quoted and in the documented forms, match the
|
|
6
|
+
files where the behaviour happens, and does the frontmatter parse? Is anything
|
|
7
|
+
in it needed before the first matching file is read or after a compaction? Does
|
|
8
|
+
it copy a page it could point to instead?
|
|
9
|
+
|
|
10
|
+
## When a rule loads
|
|
11
|
+
- An unscoped rule loads at launch with the same weight as the project instructions and is re-read after compaction, so it spends the always-loaded budget. (Claude Code)
|
|
12
|
+
- A scoped rule loads when the agent opens, creates or changes a matching file, including a single-file read through the shell such as `cat`. It arrives as conversation, so compaction summarises it away until the next matching touch. (Claude Code)
|
|
13
|
+
- Listing a directory, grepping, globbing or writing a file through a shell heredoc are not documented triggers. Do not scope a rule whose duty starts there. (Claude Code)
|
|
14
|
+
- A rule that arrives with the first write of a new file cannot shape that write. Put guidance needed before the file exists in an unscoped line.
|
|
15
|
+
- Subagents pick up matching scoped rules the same way when they work with those files. (Claude Code)
|
|
16
|
+
|
|
17
|
+
## Frontmatter and globs
|
|
18
|
+
- `paths` is the only field read; any other is ignored without warning. (Claude Code)
|
|
19
|
+
- If the YAML fails to parse, the rule loads as if it had no `paths`, in every session. Check the header after each edit; the debug log shows the parse error. (Claude Code)
|
|
20
|
+
- Quote every glob. Prefer `dir/**/*` and `**/*.ext`. A mid-path `**` is not shown in the docs, so prove it fires before relying on it, for example through the instructions-loaded hook event.
|
|
21
|
+
- Project globs resolve from the directory holding `.claude`; user rules resolve from the session's working directory. (Claude Code)
|
|
22
|
+
|
|
23
|
+
## What to put in it
|
|
24
|
+
- One topic per file, with a filename that tells a reader its subject unopened.
|
|
25
|
+
- Standing checks for that topic, worded so they can be verified, each "never" with its scope and reason. A procedure belongs in a skill or a page.
|
|
26
|
+
- Where a page already owns the content, the rule only points: one sentence of rule, the moment to open it, and where it lives, as a link or in backticks. An `@` import pulls the whole page in, which undoes the point.
|
|
27
|
+
- Team conventions go in the project's rules. A personal rule must not restate or contradict one; neither overrides the other, so the agent may follow either. (Claude Code)
|
|
28
|
+
- A loaded rule over the per-file size limit is cut to its start. Keep each file well under it. (Claude Code)
|
|
29
|
+
- Record the reason for a rule's scope in the commit message, not in a comment in the file.
|
|
30
|
+
- Rules are guidance. A rule that must always hold needs a hook, a permission or a failing check.
|
|
31
|
+
|
|
32
|
+
Sources: [memory and rules](https://code.claude.com/docs/en/memory),
|
|
33
|
+
[context window](https://code.claude.com/docs/en/context-window),
|
|
34
|
+
[hooks](https://code.claude.com/docs/en/hooks).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Skills: a description that wins selection, a lean body behind it
|
|
2
|
+
|
|
3
|
+
Every listed skill's name and description cost context on every turn, and the
|
|
4
|
+
description alone decides whether the body loads. Ask: does the description say
|
|
5
|
+
what the skill does and the concrete situations that should load it, in the
|
|
6
|
+
third person? Should a person invoke it by name instead, keeping it out of the
|
|
7
|
+
listing? Is the body lean, with detail one link away? Does the body explain why
|
|
8
|
+
rather than shout? Is this a skill at all, or a hook or a rule?
|
|
9
|
+
|
|
10
|
+
## What loads, and what it costs
|
|
11
|
+
- Names and descriptions sit in a listing shared by every personal, project and plugin skill, within a character budget scaled to the context window. When it overflows, the least used descriptions are dropped first, and a skill shown with no description rarely fires. (Claude Code)
|
|
12
|
+
- Each description is cut at a per-skill cap in the listing. Put what and when first. (Claude Code)
|
|
13
|
+
- A skill marked for manual invocation only keeps its description out of the listing. Use it for anything a person starts by name. (Claude Code)
|
|
14
|
+
- Once loaded, the body stays in context across turns, and only its opening part is re-attached after compaction. Put the standing instructions at the top. (Claude Code)
|
|
15
|
+
- Measure the listing's size after adding a skill rather than trusting a count; the docs set no limit by number of skills.
|
|
16
|
+
|
|
17
|
+
## The description
|
|
18
|
+
- Name the situations that should load it, not only the capability. Include the entry modes the model will miss: a task handed over without any triggering verb, or an edit that starts in an adjacent file.
|
|
19
|
+
- Write in the third person. Mixed point of view hurts discovery.
|
|
20
|
+
- Skills tend to under-fire, so a little insistence belongs here, in the description. Keep the body calm.
|
|
21
|
+
- Trivial one-step requests may never load a skill. For file types the skill must always govern, add `paths:` globs, and check that the host version honours them. (Claude Code)
|
|
22
|
+
- Keep the frontmatter valid YAML; a folded block avoids escaping trouble with colons and quotes. Respect the length limits on name and description.
|
|
23
|
+
|
|
24
|
+
## The body
|
|
25
|
+
- Keep it under about 500 lines. Move depth into sibling files linked directly from the body, never a chain of links.
|
|
26
|
+
- Spend lines only on what the model cannot infer: the project's cadence, gates and prohibitions. Cut any line whose removal would cause no mistake.
|
|
27
|
+
- Use the imperative and give reasons. All-caps rules are a sign to explain instead.
|
|
28
|
+
- Name the skill for the activity it governs, lowercase with hyphens, a gerund preferred; never `helper`, `utils` or `tools`.
|
|
29
|
+
|
|
30
|
+
## Choosing the carrier
|
|
31
|
+
- Procedural knowledge applied while working: a skill. A side effect that must always fire: a hook, which does its own work and never starts a skill. A heavy isolated job: a subagent or a forked skill. A rule for every session: the instructions file. (Claude Code)
|
|
32
|
+
- Prove a change with a trigger test recorded before and after: it fires on the missed case and stays quiet on near misses.
|
|
33
|
+
|
|
34
|
+
Sources: [skills](https://code.claude.com/docs/en/skills),
|
|
35
|
+
[skill authoring](https://platform.claude.com/docs/en/agents-and-tools/agent-skills/best-practices).
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Subagent definitions: shared instructions only, for a worker spawned often
|
|
2
|
+
|
|
3
|
+
The description sits in the parent's context and steers delegation; the body is
|
|
4
|
+
the worker's whole system prompt. Ask: is this worker spawned repeatedly with
|
|
5
|
+
the same instructions, or is it a one-off prompt or a skill? Does the
|
|
6
|
+
description say what it does and who spawns it, without inviting unwanted
|
|
7
|
+
automatic use? Does the body hold only what every spawn shares, without
|
|
8
|
+
restating project instructions or a runbook's steps? Are tools, model and
|
|
9
|
+
isolation set deliberately?
|
|
10
|
+
|
|
11
|
+
## What loads where
|
|
12
|
+
- The body becomes the worker's system prompt, in place of the host's own. The worker also gets the spawn prompt and the project instructions, but not the parent's conversation, loaded skills or files read. (Claude Code)
|
|
13
|
+
- Some built-in workers, and a type set to omit them, start without the project instructions, so their spawn prompt must carry any rule the work depends on. (Claude Code)
|
|
14
|
+
- Each type's description is listed to the parent so it can delegate. Keep it short and specific; every word is paid in the parent session.
|
|
15
|
+
- An edited definition is picked up within seconds without a restart. If a new type is refused by name, spawn a general-purpose worker told to read the file first. (Claude Code)
|
|
16
|
+
|
|
17
|
+
## The description
|
|
18
|
+
- State the worker's job and the runbook or role that starts it. Leave out invitations to use it proactively when a runbook spawns it by name; keeping the description narrow is all that stops unwanted delegation. (Claude Code)
|
|
19
|
+
- Keep `name` unique: a project type outranks a user type of the same name. (Claude Code)
|
|
20
|
+
|
|
21
|
+
## The body and the spawn prompt
|
|
22
|
+
- The body carries the standing instructions every spawn shares: what to check, how to report back, where to stop.
|
|
23
|
+
- Where a runbook owns the procedure, name its section and tell the worker to run it. A copy of the steps drifts.
|
|
24
|
+
- Do not restate the project instructions or rule files; the worker loads them.
|
|
25
|
+
- The spawn prompt carries what differs per task: the objective, the output format, the tools and sources, and the boundaries. Thin briefs cause duplicated work and gaps.
|
|
26
|
+
|
|
27
|
+
## Frontmatter
|
|
28
|
+
- Spell each field exactly as the reference table does; an unknown field is ignored silently. A file without `name` is treated as documentation and never reported. Validate after editing. (Claude Code)
|
|
29
|
+
- Grant only the tools the job needs. A worker cannot ask the person a question; decisions that belong to a person come back to the parent. A background worker loses most built-in tools. (Claude Code)
|
|
30
|
+
- No field limits which paths a worker may write. A write fence is either a file list in the brief or a pre-tool hook. (Claude Code)
|
|
31
|
+
- A model passed at spawn beats the file's `model`. Set `model` in the definition where the job depends on it, and do not override it by habit. (Claude Code)
|
|
32
|
+
- A worktree-isolated worker starts from the default branch, not the parent's head, and an unchanged worktree is removed. Move it to the right branch first. (Claude Code)
|
|
33
|
+
|
|
34
|
+
Sources: [subagents](https://code.claude.com/docs/en/sub-agents),
|
|
35
|
+
[extension overview](https://code.claude.com/docs/en/features-overview).
|