Skip to content

feat: print setup instructions for agents - #25

Merged
webern merged 2 commits into
m/densityfrom
m/instructions
Sep 24, 2026
Merged

webern merged 2 commits into
m/densityfrom
m/instructions

Conversation

@webern

@webern webern commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Human Summary

The idea here is that the agent itself can use the deslag instructions command to understand how to set up a repo with deslag.

Summary

Adds deslag instructions, a command whose output is written for an agent rather than a person. Onboarding becomes: cargo install deslag, then tell your agent to run deslag instructions and follow them. The README says so in two lines.

This one is a command, not a lint, so there is nothing to configure. The configurability work here is in the schema.

The guide

deslag instructions prints a Markdown guide to standard output. It walks the agent through:

  1. finding the config, or choosing where to put one;
  2. choosing which files to lint, and asking before linting files a human writes, such as README.md;
  3. writing a config, from an example that turns on every lint;
  4. running deslag check, then proposing limits to the human with what each would fail;
  5. fixing the files an agent wrote, and asking about the ones a human wrote;
  6. wiring deslag check into CI;
  7. if it suits the project and the human agrees, adding a note about deslag check to AGENTS.md.

The rule running through it: the human owns the limits. The agent proposes them and never raises one, or adds an override or a frontmatter budget, just to get past a check.

The guide lives in src/instructions/guide.md and is compiled in with include_str!, so Cargo.toml's include now takes /src/**/*.md too. The config paths, extensions, schema version and deslag version are filled in from the code. This repo's own deslag config lints the guide, with a 5000 byte budget, so it cannot bloat.

The schema

deslag instructions config-schema prints the JSON schema of the config, draft 7. It comes from schemars (a new dependency, 1.2.2, which brings in 5 small crates) deriving JsonSchema on the same types the config is read into, so a new lint or setting shows up in the schema without anyone remembering to add it. It serves TOML and YAML configs too, and editors can use it: taplo for TOML, yaml-language-server for YAML.

What the derive does not know, I added by hand:

  • the real defaults, taken from the code's constants (600 and 300 for density, the repo_layout defaults, ["*.md"] for globs), instead of the null that #[serde(default)] produces;
  • each banned_chars group's default, which a test ties to the GROUPS table;
  • the ranges deslag enforces: max_percent 0 to 100, density limits at least 1, schema_version at most the version this build reads.

Doc comments on the config types become the schema's descriptions, so I removed the rustdoc links and the "On by default" wording that the default keyword now carries.

Room for #17

instructions takes an optional topic as a subcommand. #17's deslag instructions --from 2 --to 6 can be added as flags on instructions without changing what exists. I have not built any of it.

A small fix along the way

deslag instructions | head panicked on the closed pipe. The command now writes to stdout and treats a broken pipe as success, since agents pipe output into head all the time.

This PR is stacked on #23.

Testing

  • make ci: exit 0
  • make check-publish: exit 0, and the package lists src/instructions/guide.md
  • tests/instructions.rs, 9 tests:
    • the command prints the guide, and config-schema prints the schema;
    • no placeholder is left in the guide, and it names every lint;
    • the example config names every lint, passes deslag check, and fits the schema;
    • every config in tests/cases that deslag accepts fits the schema;
    • nine configs deslag refuses are refused by the schema too;
    • every table in the schema refuses unknown keys;
    • each group's default in the schema matches GROUPS.
  • Mutations, each caught by a test:
    • dropping a range;
    • flipping a group default;
    • loosening max_percent;
    • dropping the schema version maximum;
    • dropping a lint from the guide or the example;
    • leaving a placeholder unfilled.

References

@webern webern added enhancement New feature or request area/config Has to do with deslag configuration (deslag.yaml, etc.) area/cli Deals with the command line interface. labels Sep 24, 2026
@webern
webern added this pull request to stack #24 September 24, 2026 15:12
Comment thread Cargo.toml Outdated
Comment on lines 13 to 14
# The published crate holds what a consumer needs to build it and nothing else. A list of what to
# keep, rather than what to drop, so a new file (the test corpus above all) cannot slip in.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Garbage from a previous agent.

Suggested change
# The published crate holds what a consumer needs to build it and nothing else. A list of what to
# keep, rather than what to drop, so a new file (the test corpus above all) cannot slip in.

Comment thread .agents/deslag.toml Outdated
Comment on lines +2 to +3
# it. It covers the files an agent reads: AGENTS.md, the skills, and the guide `deslag instructions`
# prints.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the love of God, stop listing things (#16, which unfortunately can't cover code/config comments for yet)

Suggested change
# it. It covers the files an agent reads: AGENTS.md, the skills, and the guide `deslag instructions`
# prints.
# it.

Comment thread src/instructions/guide.md Outdated
Comment on lines +96 to +101
Add this to AGENTS.md, or whichever file agents in this repository read first:

```markdown
Run `deslag check` after editing Markdown, and fix what it reports. Do not change the deslag config
or a `max_size_bytes` in frontmatter unless a human asks you to.
```

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If appropriate in this project, make a note in AGENTS.md regarding the deslag check. Check with the user!

Add `deslag instructions`, which prints a guide for an agent setting
deslag up in a repository: where the config goes, which files to
lint, an example config that turns on every lint, how to measure and
propose limits to the human, and how to wire deslag into CI and tell
future agents about it. The config paths, extensions, schema version
and deslag version are filled in from the code.

Add `deslag instructions config-schema`, which prints the JSON schema
of the config. schemars derives it from the types the config is read
into, so a new setting shows up without a change here. The schema
carries the real defaults and the ranges deslag checks.

Tests hold the guide to every lint, the example config to every lint,
every config deslag accepts in the cases to the schema, and a set of
configs deslag refuses to the schema refusing them too.

Lint the guide with this repo's own config, under a 5000 byte budget.
Drop the comment on Cargo.toml's include and the list of covered
files from .agents/deslag.toml's header.

The guide's last step no longer hands the agent a note to paste into
AGENTS.md. It asks the agent to add one only if it suits the project,
and to check with the human first.
@webern
webern merged commit 70c6c3b into main Sep 24, 2026
2 checks passed
@webern
webern deleted the m/instructions branch September 24, 2026 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli Deals with the command line interface. area/config Has to do with deslag configuration (deslag.yaml, etc.) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implant repo onboarding commands.

1 participant