Add missing includes (#21913)

diff --git a/examples/chip-tool/commands/clusters/CustomArgument.h b/examples/chip-tool/commands/clusters/CustomArgument.h
index 6755703..63fe7d7 100644
--- a/examples/chip-tool/commands/clusters/CustomArgument.h
+++ b/examples/chip-tool/commands/clusters/CustomArgument.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <app-common/zap-generated/cluster-objects.h>
+#include <lib/support/BytesToHex.h>
 #include <lib/support/CHIPMemString.h>
 #include <lib/support/SafeInt.h>
 
diff --git a/examples/chip-tool/commands/discover/Commands.h b/examples/chip-tool/commands/discover/Commands.h
index f7a4118..b6ef1e3 100644
--- a/examples/chip-tool/commands/discover/Commands.h
+++ b/examples/chip-tool/commands/discover/Commands.h
@@ -18,9 +18,10 @@
 
 #pragma once
 
-#include "DiscoverCommand.h"
-#include "DiscoverCommissionablesCommand.h"
-#include "DiscoverCommissionersCommand.h"
+#include "commands/common/Commands.h"
+#include "commands/discover/DiscoverCommand.h"
+#include "commands/discover/DiscoverCommissionablesCommand.h"
+#include "commands/discover/DiscoverCommissionersCommand.h"
 #include <lib/address_resolve/AddressResolve.h>
 
 class Resolve : public DiscoverCommand, public chip::AddressResolve::NodeListener
diff --git a/examples/chip-tool/commands/group/Commands.h b/examples/chip-tool/commands/group/Commands.h
index 6aa59c5..e60ba68 100644
--- a/examples/chip-tool/commands/group/Commands.h
+++ b/examples/chip-tool/commands/group/Commands.h
@@ -18,11 +18,12 @@
 
 #pragma once
 
-#include "../common/CHIPCommand.h"
-#include "../common/Command.h"
-
 #include <lib/support/Span.h>
 
+#include "commands/common/CHIPCommand.h"
+#include "commands/common/Command.h"
+#include "commands/common/Commands.h"
+
 class ShowControllerGroups : public CHIPCommand
 {
 public:
diff --git a/examples/chip-tool/commands/interactive/Commands.h b/examples/chip-tool/commands/interactive/Commands.h
index 19feb20..0424904 100644
--- a/examples/chip-tool/commands/interactive/Commands.h
+++ b/examples/chip-tool/commands/interactive/Commands.h
@@ -18,10 +18,9 @@
 
 #pragma once
 
-#include "../common/CHIPCommand.h"
-#include "../common/Commands.h"
-
-#include "InteractiveCommands.h"
+#include "commands/common/CHIPCommand.h"
+#include "commands/common/Commands.h"
+#include "commands/interactive/InteractiveCommands.h"
 
 void registerCommandsInteractive(Commands & commands, CredentialIssuerCommands * credsIssuerConfig)
 {
diff --git a/examples/chip-tool/commands/pairing/Commands.h b/examples/chip-tool/commands/pairing/Commands.h
index 80506e6..4841d0c 100644
--- a/examples/chip-tool/commands/pairing/Commands.h
+++ b/examples/chip-tool/commands/pairing/Commands.h
@@ -18,10 +18,11 @@
 
 #pragma once
 
-#include "CloseSessionCommand.h"
-#include "CommissionedListCommand.h"
-#include "OpenCommissioningWindowCommand.h"
-#include "PairingCommand.h"
+#include "commands/common/Commands.h"
+#include "commands/pairing/CloseSessionCommand.h"
+#include "commands/pairing/CommissionedListCommand.h"
+#include "commands/pairing/OpenCommissioningWindowCommand.h"
+#include "commands/pairing/PairingCommand.h"
 
 #include <app/server/Dnssd.h>
 #include <commands/common/CredentialIssuerCommands.h>
diff --git a/examples/chip-tool/commands/payload/Commands.h b/examples/chip-tool/commands/payload/Commands.h
index 1b5eb2c..0cc5cae 100644
--- a/examples/chip-tool/commands/payload/Commands.h
+++ b/examples/chip-tool/commands/payload/Commands.h
@@ -18,10 +18,11 @@
 
 #pragma once
 
-#include "AdditionalDataParseCommand.h"
-#include "SetupPayloadGenerateCommand.h"
-#include "SetupPayloadParseCommand.h"
-#include "SetupPayloadVerhoeff.h"
+#include "commands/common/Commands.h"
+#include "commands/payload/AdditionalDataParseCommand.h"
+#include "commands/payload/SetupPayloadGenerateCommand.h"
+#include "commands/payload/SetupPayloadParseCommand.h"
+#include "commands/payload/SetupPayloadVerhoeff.h"
 
 void registerCommandsPayload(Commands & commands)
 {
diff --git a/examples/chip-tool/templates/ComplexArgumentParser.zapt b/examples/chip-tool/templates/ComplexArgumentParser.zapt
index 9597dc5..9ac2c70 100644
--- a/examples/chip-tool/templates/ComplexArgumentParser.zapt
+++ b/examples/chip-tool/templates/ComplexArgumentParser.zapt
@@ -1,5 +1,10 @@
 {{> header}}
 
+#include <json/json.h>
+
+#include <lib/core/CHIPError.h>
+#include <app-common/zap-generated/cluster-objects.h>
+
 {{#structs_with_cluster_name}}
 static CHIP_ERROR Setup(const char * label, {{zapTypeToEncodableClusterObjectType name ns=clusterName}} & request, Json::Value & value);
 
diff --git a/examples/chip-tool/templates/logging/DataModelLogger.zapt b/examples/chip-tool/templates/logging/DataModelLogger.zapt
index 69550b9..468f266 100644
--- a/examples/chip-tool/templates/logging/DataModelLogger.zapt
+++ b/examples/chip-tool/templates/logging/DataModelLogger.zapt
@@ -1,5 +1,8 @@
 {{> header}}
 
+#include <lib/core/CHIPError.h>
+#include <app-common/zap-generated/cluster-objects.h>
+
 {{#structs_with_cluster_name}}
 static CHIP_ERROR LogValue(const char * label, size_t indent, {{zapTypeToDecodableClusterObjectType name ns=clusterName isArgument=true}} value);
 {{/structs_with_cluster_name}}
diff --git a/examples/chip-tool/templates/tests/commands.zapt b/examples/chip-tool/templates/tests/commands.zapt
index b960267..64b9b34 100644
--- a/examples/chip-tool/templates/tests/commands.zapt
+++ b/examples/chip-tool/templates/tests/commands.zapt
@@ -5,6 +5,7 @@
 #if CONFIG_ENABLE_YAML_TESTS
 
 #include <commands/tests/TestCommand.h>
+#include <commands/common/Commands.h>
 #include <lib/core/Optional.h>
 #include <lib/support/CHIPListUtils.h>
 #include <system/SystemClock.h>
diff --git a/src/app/tests/suites/include/PICSChecker.h b/src/app/tests/suites/include/PICSChecker.h
index 28c07af..e7c7b7d 100644
--- a/src/app/tests/suites/include/PICSChecker.h
+++ b/src/app/tests/suites/include/PICSChecker.h
@@ -22,7 +22,7 @@
 
 #include <app/tests/suites/pics/PICSBooleanExpressionParser.h>
 #include <app/tests/suites/pics/PICSBooleanReader.h>
-
+#include <lib/core/Optional.h>
 #include <lib/support/logging/CHIPLogging.h>
 
 class PICSChecker
diff --git a/src/app/tests/suites/include/TestRunner.h b/src/app/tests/suites/include/TestRunner.h
index 3bdea10..9fd5450 100644
--- a/src/app/tests/suites/include/TestRunner.h
+++ b/src/app/tests/suites/include/TestRunner.h
@@ -18,6 +18,10 @@
 
 #pragma once
 
+#include <string>
+
+#include <lib/core/CHIPError.h>
+#include <lib/core/Optional.h>
 #include <lib/support/UnitTestUtils.h>
 
 class TestRunner
diff --git a/src/lib/dnssd/minimal_mdns/ResponseBuilder.h b/src/lib/dnssd/minimal_mdns/ResponseBuilder.h
index 6391d18..3341576 100644
--- a/src/lib/dnssd/minimal_mdns/ResponseBuilder.h
+++ b/src/lib/dnssd/minimal_mdns/ResponseBuilder.h
@@ -19,6 +19,7 @@
 
 #include <system/SystemPacketBuffer.h>
 
+#include <lib/dnssd/minimal_mdns/Parser.h>
 #include <lib/dnssd/minimal_mdns/core/DnsHeader.h>
 #include <lib/dnssd/minimal_mdns/records/ResourceRecord.h>
 
diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h
index f0aad84..874f778 100644
--- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h
+++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h
@@ -17,6 +17,11 @@
 
 // THIS FILE IS GENERATED BY ZAP
 
+#include <json/json.h>
+
+#include <app-common/zap-generated/cluster-objects.h>
+#include <lib/core/CHIPError.h>
+
 static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlEntry::Type & request,
                         Json::Value & value);
 
diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h
index 6eaf6cb..9b079c1 100644
--- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h
+++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h
@@ -17,6 +17,9 @@
 
 // THIS FILE IS GENERATED BY ZAP
 
+#include <app-common/zap-generated/cluster-objects.h>
+#include <lib/core/CHIPError.h>
+
 static CHIP_ERROR LogValue(const char * label, size_t indent,
                            const chip::app::Clusters::AccessControl::Structs::AccessControlEntry::DecodableType & value);
 static CHIP_ERROR LogValue(const char * label, size_t indent,
diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h
index bdd9b18..3b2a0ea 100644
--- a/zzz_generated/chip-tool/zap-generated/test/Commands.h
+++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h
@@ -21,6 +21,7 @@
 
 #if CONFIG_ENABLE_YAML_TESTS
 
+#include <commands/common/Commands.h>
 #include <commands/tests/TestCommand.h>
 #include <lib/core/Optional.h>
 #include <lib/support/CHIPListUtils.h>