Key behavior:
- Detect tech stack from config file markers
- Discover and validate build/test/lint commands by running them
- Analyze git history for commit conventions and common issues
- Detect CI configuration
- Generate all 6 AGENTS.md sections from collected data
- Present complete AGENTS.md for user approval before writing
- Back up existing AGENTS.md before overwriting
Node/TypeScript/Bun:
package.json- Node.js projectbun.lockb- Bun runtimepnpm-lock.yaml- pnpm package manageryarn.lock- Yarn package managertsconfig.json- TypeScript configuration
Rust:
Cargo.toml- Rust/Cargo projectrust-toolchain.toml- Rust toolchain config
Python:
pyproject.toml- Modern Python projectrequirements.txt- Python dependenciessetup.py- Legacy Python packagingPipfile- Pipenv project
Go:
go.mod- Go modulego.sum- Go dependency checksums
Build tools (cross-language):
justfile- Just command runnerMakefile- Make build systemTaskfile.yml- Task runner
# Detection script
for f in package.json bun.lockb pnpm-lock.yaml yarn.lock tsconfig.json \
Cargo.toml rust-toolchain.toml \
pyproject.toml requirements.txt setup.py Pipfile \
go.mod go.sum \
justfile Makefile Taskfile.yml; do
if [ -f "$f" ]; then
echo "DETECTED: $f"
fi
done
Record all detected config files. A project may have multiple stacks (monorepo).
justfile- Just command runner (highest priority)Makefile- MakeTaskfile.yml- Taskpackage.jsonscripts - npm/yarn/pnpm/bun- Language-specific tools (cargo, go, pytest, etc.)
All detected tools should be documented, but the highest-priority tool's commands are listed first.
# List all recipes
just --list 2>/dev/null
Extract recipe names and map to command categories:
- Recipes containing
test-> Test commands - Recipes containing
checkortypecheck-> Typecheck commands - Recipes containing
lintorclippy-> Lint commands - Recipes containing
build-> Build commands - Recipes containing
validate-> Full validation commands - Recipes containing
dev-> Development commands - All other recipes -> Utility commands
# Extract script names
cat package.json | jq -r '.scripts // {} | keys[]' 2>/dev/null
Map script names to categories:
test,test:*-> Test commands (run withnpm test/bun testetc.)typecheck,tsc,check-types-> Typecheck commandslint,lint:*,eslint-> Lint commandsbuild,build:*-> Build commandsdev,start,serve-> Development commands
Use the detected package manager (bun/pnpm/yarn/npm) for the run command prefix.
# Extract target names (exclude internal targets starting with .)
make -qp 2>/dev/null | grep -E "^[a-zA-Z][a-zA-Z0-9_-]*:" | cut -d: -f1 | sort -u
Map target names to categories using the same keyword matching as justfile.
# For each command, run with timeout and capture result
timeout 60 {command} 2>&1
echo "EXIT_CODE: $?"
Record for each command:
- Command string: The exact command to run
- Exit code: 0 = working, non-zero = failing
- Brief output: First/last few lines if relevant
Timeout: 60 seconds per command. If a command times out, mark it as (timeout — may need manual configuration).
Commands to validate (in order of importance):
- Test command (e.g.,
just test,npm test) - Typecheck command (e.g.,
just typecheck,npm run typecheck) - Lint command (e.g.,
just lint,npm run lint) - Build command (e.g.,
just build,npm run build)
Do NOT validate:
- Development servers (
dev,start,serve) — they don't exit - Clean/reset commands — they may delete needed files
- Deploy/publish commands — they affect production
Working command:
- `just test` - Run all unit tests (validated ✓)
Failing command:
- `just test` - Run all unit tests (⚠ exits with code 1 — check test configuration)
Timed-out command:
- `just test` - Run all unit tests (⚠ timed out after 60s — may need manual configuration)
# Generate tree excluding noise directories, depth limited to 3
find . -maxdepth 3 \
-not -path './.git/*' \
-not -path './.git' \
-not -path './node_modules/*' \
-not -path './node_modules' \
-not -path './target/*' \
-not -path './target' \
-not -path './__pycache__/*' \
-not -path './__pycache__' \
-not -path './.venv/*' \
-not -path './.venv' \
-not -path './venv/*' \
-not -path './venv' \
-not -path './.next/*' \
-not -path './.next' \
-not -path './dist/*' \
-not -path './dist' \
-not -path './build/*' \
-not -path './build' \
-not -path './.cache/*' \
-not -path './.cache' \
-not -path './.mobius/*' \
-not -path './.mobius' \
-type d \
| sort | head -60
Format as an indented tree with brief annotations for key directories.
# Count file extensions
find . -type f \
-not -path './.git/*' \
-not -path './node_modules/*' \
-not -path './target/*' \
-not -path './__pycache__/*' \
-not -path './.venv/*' \
| sed 's/.*\.//' | sort | uniq -c | sort -rn | head -15
From the extension counts and directory structure, identify:
- Source code location: Where main source files live
- Test patterns: How tests are organized (co-located, separate directory, naming convention)
- Type definitions: Where types/interfaces are defined
- Component patterns: UI component organization (if applicable)
- Naming conventions: camelCase, snake_case, PascalCase for files/directories
- Entry points (main.rs, index.ts, app.py, main.go)
- Configuration files (tsconfig.json, Cargo.toml, pyproject.toml)
- CI configuration (.github/workflows/*.yml)
- Environment files (.env.example, .env.local)
- Lock files and their package manager
# Find likely entry points
for f in src/main.rs src/main.ts src/index.ts src/index.js \
src/app.ts src/app.py main.go cmd/main.go \
src/lib.rs src/mod.rs; do
if [ -f "$f" ]; then
echo "ENTRY: $f"
fi
done
# Get recent commit messages
git log --oneline -20 2>/dev/null
Analyze the output to detect:
- Conventional commits:
type(scope): descriptionpattern - Issue references:
MOB-123,JIRA-456,#123patterns - Prefix patterns:
feat:,fix:,chore:etc. - Free-form: No consistent pattern
Generate a summary of the convention with examples from actual commits.
# Recent fix commits
git log --oneline --grep='fix' -20 2>/dev/null
# Recent revert commits
git log --oneline --grep='revert' -10 2>/dev/null
Analyze fix/revert commits to identify recurring issues:
- What areas of the codebase need frequent fixes?
- Are there common patterns (e.g., type errors, test failures, import issues)?
- Generate actionable guidance from these patterns.
# Most frequently modified files in recent history
git log --name-only --pretty=format: -50 2>/dev/null | \
grep -v '^$' | sort | uniq -c | sort -rn | head -10
These files are important context — they're where most development activity happens.
# Check if git is initialized and has commits
git rev-parse HEAD 2>/dev/null
If no git history:
- Skip commit conventions section (or note "No commit history yet")
- Skip common issues section
- Skip hot files analysis
- Include a note: "Git history analysis will be more useful after initial development"
# List workflow files
ls .github/workflows/*.yml .github/workflows/*.yaml 2>/dev/null
For each workflow file, extract:
- Trigger events: push, pull_request, schedule, workflow_dispatch
- Key jobs: build, test, lint, deploy
- Required checks: What must pass before merge
# For each workflow file
for f in .github/workflows/*.yml .github/workflows/*.yaml; do
if [ -f "$f" ]; then
echo "=== $f ==="
head -20 "$f"
fi
done
# Check for common CI configs
for f in .circleci/config.yml .travis.yml Jenkinsfile \
.gitlab-ci.yml bitbucket-pipelines.yml \
azure-pipelines.yml .buildkite/pipeline.yml; do
if [ -f "$f" ]; then
echo "CI_DETECTED: $f"
fi
done
If detected, read the config file header to identify key jobs and triggers.
Generate from validated commands. Group by category:
## Build & Validation
Run these commands after implementing changes to get immediate feedback:
**Build & Validation:**
- `{command}` - {description} ({validation status})
...
**Development:**
- `{command}` - {description}
...
**Utilities:**
- `{command}` - {description}
...
Rules:
- List validated (working) commands first
- Note failing commands with their error
- Include the exact command string to run
- Group logically (validation, development, utilities)
- If a command runner (just/make) is detected, show its commands prominently
Generate from commit conventions and general guidelines:
## Operational Notes
Guidelines for autonomous execution:
- **Commit convention**: {detected convention with examples}
- Always run validation commands after making changes
- Commit frequently with descriptive messages
- If tests fail, fix them before moving to the next sub-task
- When blocked, add a comment to the issue explaining the blocker
- Prefer small, focused changes over large refactors
Rules:
- Include detected commit convention with real examples from git log
- Include standard autonomous execution guidelines
- Add any project-specific notes detected from README or CONTRIBUTING files
Generate from file pattern analysis:
## Codebase Patterns
- **{category}**: `{path}` - {description}, {naming convention}
...
Rules:
- Document actual detected patterns, not template placeholders
- Include naming conventions (camelCase, snake_case, PascalCase)
- Note test file patterns (co-located, separate dir, naming suffix)
- Include type/interface patterns
- Mention key architectural patterns (if detectable)
Generate from git history analysis:
## Common Issues
Known gotchas and their solutions:
- **{issue}**: {description and solution}
...
Rules:
- Derive from actual fix/revert commits in git history
- Include actionable solutions, not just problem descriptions
- If no git history, include general best practices for the detected stack
- Note any workspace/path issues detected from project structure
Generate from directory tree analysis:
## Project Structure
{project-name}/ ├── {dir}/ # {annotation} │ ├── {subdir}/ # {annotation} ...
Rules:
- Use the depth-limited tree from codebase analysis
- Annotate key directories with their purpose
- Exclude noise directories (.git, node_modules, target, pycache, .venv)
- Limit depth to 3 levels to keep it concise
Generate based on .mobius/ directory presence:
## Mobius-Specific Instructions
{instructions for the autonomous Mobius loop}
If .mobius/ directory exists:
- Note the issue tracking backend (from
mobius.config.yamlif present) - Reference any files that should not be modified
- Include branch naming conventions if detectable
- Note any special loop configuration
If .mobius/ directory does NOT exist:
- Include generic Mobius instructions
- Note that the project can be configured with
mobius init
- Title:
# AGENTS.md - Description line:
Operational guide for autonomous {tool} execution.(where {tool} is detected from .mobius/ presence or defaults to "Claude") - All 6 sections in order
- No template placeholder content — every line must contain real detected data or be omitted entirely
Use AskUserQuestion to show the generated content and get approval:
Question: "Here is the generated AGENTS.md for your project. Should I write it?"
Options:
- "Write it" (description: "Write the AGENTS.md file to the project root")
- "Edit first" (description: "Let me make changes to the content before writing")
- "Cancel" (description: "Don't write the file")
Before presenting, output the complete generated AGENTS.md content so the user can review it.
If "Write it": Proceed to file write phase. If "Edit first": Ask what changes the user wants, apply them, then present again. If "Cancel": Stop execution without writing.
if [ -f "AGENTS.md" ]; then
cp AGENTS.md AGENTS.md.bak
echo "Backed up existing AGENTS.md to AGENTS.md.bak"
fi
Always back up before overwriting.
After writing, confirm:
test -f AGENTS.md && echo "AGENTS.md written successfully" || echo "AGENTS.md write failed"
| Scenario | Handling |
|---|---|
| Monorepo | Detect multiple config files at root and in subdirectories. Document each stack separately in Build & Validation. Note workspace/package structure in Project Structure. |
| No build tool | Skip command validation. List detected source file types. Note "No build tool detected — consider adding a justfile or Makefile." |
| Command failure | Include failed commands in AGENTS.md with error note (e.g., (⚠ exits with code 1)). Do NOT silently omit them. |
| Large repo | Limit directory tree to depth 3 and 60 entries. Limit git log analysis to 50 recent commits. Skip file extension counting if >10,000 files. |
| No git history | Skip commit conventions, common issues, and hot files sections. Note "No git history available" in Operational Notes. |
Don't generate template placeholders: Every section must contain real detected data. If a section would only have placeholder content, omit it entirely.
Don't hardcode repo-specific content: The skill must work on any supported project. All content comes from detection, not assumptions.
Don't modify any project files (except AGENTS.md): This skill only reads the codebase and writes AGENTS.md. It should never modify source code, configs, or other files.
Don't run destructive commands: Never run clean, reset, deploy, or publish commands during validation.
Don't skip the approval gate: Always present the generated AGENTS.md for user approval before writing. Never write without asking.
Don't include development server commands in validation: Commands like dev, start, serve don't exit and will timeout. Document them but don't run them.
- Tech stack detected from config file markers
- Build/test/lint/typecheck commands discovered from build tool
- Discovered commands validated by running them (with exit code captured)
- Directory structure generated excluding noise directories (.git, node_modules, target, pycache, .venv)
- Commit conventions detected from git log analysis
- Common issues identified from fix/revert commit patterns
- CI configuration detected from .github/workflows/
- All 6 AGENTS.md sections generated with real detected data
- Existing AGENTS.md backed up to AGENTS.md.bak before overwriting
- Complete AGENTS.md presented for user approval via AskUserQuestion
- File written only after user approval
- No template placeholder content in final output — every section has real data or is omitted
Converted and distributed by TomeVault — claim your Tome and manage your conversions.