Skip to content

Synforger/agent-template

Repository files navigation

agent-template

πŸ‡―πŸ‡΅ ζ—₯本θͺžη‰ˆ: README.ja.md

A scaffold for long-lived agents running on Claude Code / the Anthropic SDK. Machinery, structural templates, and a revision culture live in one base; each derived agent is spun up with init-new-agent.sh and shares improvements through two-way sync.

Design ideas

  • An agent is persona + its own projects + machinery. The machinery is factored into this base; persona and projects stay in the derived repo β€” so machinery improvements are shared by every agent.
  • A continuous self-reinforcement loop. Machinery quality is swept mechanically (docs-check.sh / detect-duplicates.py / detect-stale-rules.sh); the agent only reacts to the output, spending no context on re-derivation.
  • Built to be published. Personal and workplace identifiers are blocked mechanically at the commit / push boundary by the machine-resident guard-dispatcher (a separate repo).
  • Minimal constraints on derivations. The base owns only the machinery, the required rule file, and the structural templates; everything else is the derivation's free territory.

Repository layout

agent-template/
β”œβ”€β”€ LICENSE                            # Apache 2.0
β”œβ”€β”€ README.md / README.ja.md           # this file + Japanese version
β”œβ”€β”€ .gitignore                         # the template repo's own gitignore
β”œβ”€β”€ .githooks/pre-commit               # branch guard (anon scanning is delegated to guard-dispatcher)
β”œβ”€β”€ .tooling/local-ci/                 # the template repo's own docs lint
β”‚   β”œβ”€β”€ docs-lint.sh
β”‚   β”œβ”€β”€ docs-check-ignore.txt
β”‚   └── setup-lib.sh
β”œβ”€β”€ .tooling/                          # template operation scripts
β”‚   β”œβ”€β”€ init-new-agent.sh              # spin up a derivation
β”‚   β”œβ”€β”€ sync-from-base.sh              # base β†’ derivation (pull down)
β”‚   └── promote-to-base.sh             # derivation β†’ base (promote up)
β”œβ”€β”€ .synced-paths.txt                  # the paths shipped down to derivations
└── src/                               # β˜… what a derived agent receives
    β”œβ”€β”€ CLAUDE.template.md             # becomes the derivation's CLAUDE.md (persona)
    β”œβ”€β”€ .gitignore.template            # expands to the derivation's .gitignore
    β”œβ”€β”€ .tooling/                      # machinery scripts (the truth that runs in derivations)
    β”‚   β”œβ”€β”€ docs-check.sh              # multi-axis docs verification
    β”‚   β”œβ”€β”€ detect-duplicates.py       # section-level duplicate detection
    β”‚   β”œβ”€β”€ detect-stale-rules.sh      # 7-day-stale rule detection
    β”‚   β”œβ”€β”€ extract-artifact-index.sh  # for a SessionEnd hook
    β”‚   β”œβ”€β”€ first-prompt-pull.sh       # multi-machine sync (optional)
    β”‚   β”œβ”€β”€ precommit-conflict-check.sh
    β”‚   β”œβ”€β”€ setup-hooks.sh             # hook install
    β”‚   β”œβ”€β”€ startup-status.sh          # run at session boot
    β”‚   └── _README.md
    β”œβ”€β”€ rules/
    β”‚   β”œβ”€β”€ always.md                  # β˜… required: capacity management + revision culture + the loop
    β”‚   └── lazy/
    β”‚       β”œβ”€β”€ _template.md           # scaffold for new lazy rules
    β”‚       └── automation-machinery.md
    β”œβ”€β”€ projects/_template-project/    # project scaffold (nested subprojects included)
    β”œβ”€β”€ journal/                       # session log structure
    β”œβ”€β”€ todos/                         # cross-cutting tasks
    β”œβ”€β”€ plans/                         # cross-cutting plans
    β”œβ”€β”€ research/                      # cross-cutting research
    └── profile/                       # user profile structure
        └── profile-core.template.md

Everything under src/ is the derived agent's content; everything at the root operates the template itself. init-new-agent.sh rsyncs src/ into the derivation root and expands every *.template into a real file.

Spinning up a derivation

git clone git@github.com:synforger/agent-template.git
cd agent-template
./.tooling/init-new-agent.sh ~/path/to/<new-agent>

Then, inside the derivation:

  1. Edit CLAUDE.md (persona / user relationship / agent constellation)
  2. Edit profile/profile-core.md (your primary user's core + judgement axes)
  3. Add your private vocabulary to the machine-side guard-dispatcher word list (~/.config/anon-words/)
  4. Add derivation-specific rules to rules/always.md (git conventions, prohibitions, and so on)
  5. git remote add origin <your-repo> and push

Two-way sync

Base β†’ derivation (pull down)

When a derivation wants the latest base:

cd ~/path/to/<your-agent>
./.tooling/sync-from-base.sh

Only the paths listed in .synced-paths.txt are overwritten with the base version; derivation-specific files are never touched. Review with git diff, then commit.

Derivation β†’ base (promote up)

When a derivation discovers a machinery improvement worth sharing:

cd ~/path/to/<your-agent>
./.tooling/promote-to-base.sh "feat: add a new docs-check step"

This cuts a feature branch on the base, pushes it, and the change lands via a pull request. Files outside .synced-paths.txt are rejected.

Conflict policy

  • Always run sync-from-base.sh before promoting (resolve conflicts on the derivation side).
  • If a derivation wants to override a base file permanently, the policy is the derivation's choice: keep a differently-named local file, propose the change upstream via PR, or edit its local .synced-paths.txt to exclude the path.

Required rules (do not delete in derivations)

The template ships only these; below this floor the machinery stops working.

  • rules/always.md Β§ meta β€” capacity management, revision culture, and the self-reinforcement loop (single-file form)
  • rules/lazy/_template.md β€” scaffold for new lazy rules
  • rules/lazy/automation-machinery.md β€” operational truth for .tooling/*

Derivation-specific rules (git conventions, prohibitions, subagent discipline, anything else) go freely into the derivation's rules/always.md / rules/lazy/*.md; rule content is not synced.

Machinery core

docs-check.sh

Run at session end; any FAIL must be fixed within the same session. Verification axes (the script's own step output is the truth):

  1. frontmatter
  2. capacity (self-declared per file)
  3. index consistency (_README.md ↔ sibling .md files)
  4. dead links
  5. leftover placeholders (unfilled scaffolds)
  6. dynamic-search-pattern residue
  7. project folder consistency
  8. synced-paths consistency (derivations only, diffed against base)

detect-duplicates.py

Compares every rule at H2/H3 section granularity via longest-common-substring and reports consolidation candidates for split truths. Pairs judged as intentional shared references go into .tooling/duplicates-allowlist.txt for permanent suppression β€” no re-judging every session.

detect-stale-rules.sh

No update for 7 days = retirement candidate. Files with frontmatter stable: true and _README.md files are excluded mechanically, so only genuine dead-rule candidates are reported.

The self-extension loop

Observe the same weakness twice, mechanise it immediately:

  1. Assess whether it is machine-detectable (grep / awk / python)
  2. If so, add a step to docs-check.sh or sharpen a detect-* script
  3. If not, write it into rules/always.md Β§ meta as discipline

The bar for "add a detector" is kept deliberately low β€” quality holds because the agent only has to react to machine output.

Anonymity (for public publication)

The base ships with zero concrete agent names or operator identifiers. Scanning itself lives in the machine-resident guard-dispatcher (a separate repo) and is enforced for every repo at the commit / push boundary; the word list lives in machine config (~/.config/anon-words/) and is never committed.

License

Apache License 2.0

Related

  • Synforger β€” the organisation this template ships from
  • Claude Code (Anthropic) β€” the harness this scaffold targets

About

Long-lived agent template for Claude Code: self-strengthening machinery, dual-direction sync (init/sync/promote), OSS-publishable structure.

Topics

Resources

License

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors