Skip to content

Explain that only one project config file is read - #682

Merged
schlessera merged 1 commit into
wp-cli:mainfrom
ekamran:shifteq/config-one-project-file
Nov 27, 2026
Merged

schlessera merged 1 commit into
wp-cli:mainfrom
ekamran:shifteq/config-one-project-file

Conversation

@ekamran

@ekamran ekamran commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The "Config files" section lists wp-cli.local.yml and wp-cli.yml one after the other, which reads as if WP-CLI loads both. It loads only one: Runner::get_project_config_path() looks for wp-cli.local.yml, then wp-cli.yml, in the current folder and then each parent folder, and stops at the first file it finds. In a folder with both, wp-cli.yml is ignored.

This came up in wp-cli/wp-cli#5784, where the answer was to inherit wp-cli.yml from wp-cli.local.yml. This PR adds that to the page.

Changes

  • One paragraph under the list in "Config files": only one project config file is read, which one wins, and how to use both with _: inherit: wp-cli.yml.
  • A note that the global config file is still read.

Verification

Checked with WP-CLI 2.12.0 and current main, using an alias in each config file to see which files were read (wp cli alias list) and wp cli info for the project config path:

  • wp-cli.local.yml and wp-cli.yml in the same folder: only the aliases from wp-cli.local.yml and ~/.wp-cli/config.yml are listed.
  • Same folder, with _: inherit: wp-cli.yml in wp-cli.local.yml: aliases from all three files are listed, and an alias defined in both project files keeps the value from wp-cli.local.yml.
  • wp-cli.yml in the current folder and wp-cli.local.yml in its parent: only the nearer wp-cli.yml is read.
  • An empty wp-cli.local.yml next to wp-cli.yml is enough to stop wp-cli.yml from being read.
  • Ran git diff --check.

Use of AI

AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: checking the config loading code, testing it against WP-CLI 2.12.0 and main, drafting the change, and reviewing it. I reviewed the reasoning and test results, and I take responsibility for the contribution.

Summary by CodeRabbit

  • Documentation
    • Clarified how WP-CLI selects project config files, including precedence when both are present.
    • Added guidance for loading both project config files and confirmed that the global config is still read.

The Config files section lists wp-cli.local.yml and wp-cli.yml as if
both are read. WP-CLI uses only the first of them it finds, so in a
folder with both, wp-cli.yml is ignored unless wp-cli.local.yml
inherits it.
@ekamran
ekamran requested a review from a team as a code owner November 27, 2026 11:39
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The config reference now describes project config selection during upward search, precedence when both project config files exist, inheritance through _ and inherit, and continued loading of the global config.

Changes: Project Config Documentation

Layer / File(s) Summary
Project config selection and inheritance
references/config.md
The reference documents that WP-CLI selects one project config during upward search. It states that wp-cli.local.yml takes precedence over wp-cli.yml in the same directory and shows how to inherit wp-cli.yml. It also clarifies that the global config remains included.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Other

Suggested labels: scope:documentation

Suggested reviewers: swissspidy

Merge Risk: Minimal · up to d8363

This documentation update clarifies how WP-CLI selects and inherits project config files and that the global config is still read. It does not change runtime behavior and is ready to merge.

Architecture risk: Low · up to d8363

The change affects 1 source area.

Changed areas: references

Review details

Systems and components

  • observed — 1 changed file mapped to references.

Before / after behavior

  • observed — Modified behavior in references/config.md: The documentation now specifies that only one project config is selected during the upward search, with wp-cli.local.yml preferred over wp-cli.yml when both exist. It documents inheriting wp-cli.yml from wp-cli.local.yml using _ and inherit, and says the global config remains included.
Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title "Explain that only one project config file is read" matches the main change. The raw summary says the Config files section now states that WP-CLI reads only the first project config file fou…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Explain that only one project config file is read" matches the main change. The raw summary says the Config files section now states that WP-CLI reads only the first project config file found while searching upward, with wp-cli.local.yml taking precedence over wp-cli.yml in the same directory. The title is short, specific, and uses no vague terms.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8e3760fe-8e0b-486b-b0b8-2d47c986820a
Commits

Reviewing files that changed from the base of the PR and between 4205ac3 and d83633f.

Files selected for processing: 1

  • references/config.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@schlessera schlessera left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for clarifying this behavior and adding the _: inherit: wp-cli.yml example, @ekamran! LGTM.

@schlessera
schlessera merged commit 7fb7dd2 into wp-cli:main Nov 27, 2026
8 checks passed
@ekamran
ekamran deleted the shifteq/config-one-project-file branch November 27, 2026 15:04
@schlessera schlessera added this to the 3.0.0 milestone Dec 1, 2026 — with schlessera-agent-fleet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants